HTTP Error 302 using uploadify
Asked Answered
J

7

9

I use uploadify to upload files into my web site.

It works with one hosting company. And doesn't with other company (sweb.ru).

Error is: HTTP error: 302.

Does Anybody know how to resolve this problem. Thanks.

Jabe answered 7/1, 2011 at 10:49 Comment(2)
302 is a redirect status code, so there is probably a redirection taking place somewhere along the line. It's impossible to tell where without seeing some code. Maybe there is a redirect somewhere in the .htaccess files?Freedom
php_flag magic_quotes_gpc 0 php_flag magic_quotes_runtime 0 - in .htaccessJabe
T
21

For anyone having this problem with Uploadify and a PHP Framework (e.g., CodeIgniter, CakePHP, Kohana, Yii, etc.):

Flash will not pass through your existing PHP Session information, so if you are getting the 302 error it is likely that your application is returning the login URL to the Flash player. To resolve this issue, you could include the session information in scriptData and manage it manually in your application.

Tetherball answered 19/6, 2011 at 14:10 Comment(3)
What session information needs to be managed if you pass it through scriptData?Ammunition
It depends on your needs, but it might be sufficient to pass through the session ID and have your target load the session that way. I appreciate it is not best practice to have the session appear on the page as a flash parameter, but in this instance it is definitely the easiest way to integrate Uploadify into an application that requires authentication.Tetherball
Here's a quick writeup about getting Uploadify to play nicely with Kohana sessions: serializethis.com/…Elizbeth
J
3

Problem was solved by adding "SecFilterEngine Off" in htaccess

Jabe answered 11/1, 2011 at 12:15 Comment(1)
This is for Apache 1.x, not 2.x FYIBesse
K
3

Remember that you may have to stop the redirect. I'm using cakephp. To stop the auth from triggering when the uploadify / ajax method is called you have to add the following to the controller.

  public function beforeFilter()
    {
        parent::beforeFilter();

        $this->Auth->allowedActions = array('admin_attach');
    }

"admin_attach" is the method that is called by uploadify in my view.

$(document).ready(function() {
  $('.image-attach').uploadify({
    'uploader'  : '/uploadify/uploadify.swf',
    'script'    : '/admin/featureds/featured_resources/attach/',
    'cancelImg' : '/uploadify/cancel.png',
    'buttonText' : 'Select image',
    'fileDataName' : 'uploadify',
    'auto'      : true,
   onComplete   : function(event, id, fileObj, resp, data){
                    alert(resp);
                 }
    });
});
Kiva answered 19/9, 2011 at 10:20 Comment(1)
I was doing the same but it is not OK. I managed to make it work without giving forced access to uploading method...Clubman
F
1

As said, 302 is a redirect status code, so there is probably a redirection taking place somewhere along the line.

You may have to ask the hosting company. My first suspicion would be that you're posting to a domain that has forwarding activated, e.g. domain.com => www.domain.com.

Freedom answered 7/1, 2011 at 11:24 Comment(2)
I'm quite sure Pekka is right. try to capture real web traffic with live http headers on Firefox (most other tools won't see file upload traffic) and check the response headers.Priscella
Just a note on live http headers....a great tool, but won't capture the output from uploadify since the post is hidden inside of swf uploader and isn't exposed through firefox.Principal
T
0

Try this in the beginning of the entry-script:

if (isset($_POST['PHPSESSID']))
{ 
$_COOKIE['PHPSESSID'] = $_POST['PHPSESSID'];
}

The session component will then read the correct session id from the cookie as usual.

i got this from Yii-framework forum

Terrigenous answered 2/7, 2012 at 19:43 Comment(0)
T
0

Just worked on a project that had this problem. I had a profile image which I wanted to update, but continued to receive this error in Firefox. I soon realized that the original images that uploadify was trying to overwrite were uploaded via FTP as a different user than the public web service user. Even when permissions were set to 777, that 302 error continued to occur. I removed the images via FTP and let the web user upload the fresh ones. Then I was able to overwrite the images, cancelling out the 302 error I was receiving.

Transmittance answered 9/2, 2013 at 0:8 Comment(0)
E
0

For those using the Kohana PHP framework who are struggling to get Uploadify to work with sessions, here's a quick writeup on how to make it play nice:

http://www.serializethis.com/using-uploadify-and-kohana-without-http-error-302/

Elizbeth answered 20/2, 2013 at 2:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.