Well, we all know how annoying this error can be, and I thought I’d share some possible fixes. First, let’s clarify why this happens.
Uploadify uses a Flash object to handle the uploading of a file, and then copies the file to the server by invoking a PHP script. When errors happen executing that HTTP request to the PHP script, we don’t get much to go on. Flash can only really tell us that the server came back with an error code (not 200).
To help debug, you can use UploadifyField::show_debug(); in your _config.php. This will not only show you how the Uploadify widget is configured, but also force some text into the server response so that you can get more than just a 500 code if something fails, and it will show that text in an alert box. This doesn’t always work, however, especially if the error happens before the controller is executed.
Here are some tips on troubleshooting:
1) Make sure error reporting is cranked up, and that “display_errors” is on in php.ini
3) If you get a 400 code (bad request), chances are you have mod_security running, and it might be set a little too paranoid. You can talk to your sysadmin to either turn it off, or better yet, turn it down to be more tolerant of Flash requests.
4) If you get a 302 (redirect) response, it means Flash didn’t carry over the session through PHPSESSID, and you’re therefore not authenticated in the CMS to do the upload. This is the most common and most troubling result, but I have managed to fix this on three separate occasions with the same fix:
If you are on Rackspace “cloud” hosting
This can help you. You need to change your session.save_path setting.
First, find out your document root, using Director::baseFolder(); It should look something like this:
Create a directory at the same level as your_site.com called “sessions”. It should be ABOVE the web root.
Add this to your .htaccess:
php_value session.gc_probability 1
php_value session.gc_divisor 100
php_value session.gc_maxlifetime 3600
php_value session.save_path /mnt/xxx/xxx/xxx/your_site.com/sessions
Where the “xxx” is for you to fill in according to your actual document root.
Who knows why, but for some reason, Rackspace cloud hosting has very weird session handling with Flash.
Feel free to add any of your own solutions below!