CodeIgniter Forums
CI Controller run/executes twice (using SWFUpload) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: CI Controller run/executes twice (using SWFUpload) (/showthread.php?tid=25652)



CI Controller run/executes twice (using SWFUpload) - El Forum - 12-19-2009

[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