Welcome Guest, Not a member yet? Register   Sign In
CI Controller run/executes twice (using SWFUpload)
#1

[eluser]Peng Kong[/eluser]
Does your controller run twice when you load a page? Are you using SWFUpload?
If your answer to both questions is 'Yes!' Read on.

Ok just one more question lol. Did you specify "button_image_url"?
If your answer is 'no', that's what causing the problem!

When using the SWFUpload library with Codeigniter you MUST always specify button_image_url.
If you're don't need a button image try using a transparent 1px by 1px gif.

Quote:var swfu = new SWFUpload({
...
// Button settings
button_placeholder_id: "btnPhotoUpload",
button_image_url: "images/blank.gif",
...
});

Explanation
Loading an external resource (img, js, etc) that isn't there (invalid url) causes our beloved CI to execute the controller again. The swfupload.swf always does a GET request to the 'button_image_url' and if you didn't specify it 404 occurs causing CI to re-run it's controller.

Hope this helps someone Smile




Theme © iAndrew 2016 - Forum software by © MyBB