Search code examples
javascriptjqueryuploadify

Uploadify doesn't work on IE and chrome browsers and gives HTTP ERROR


I have setup uploadify which works fine on Firefox with mulitple image uploads. However, it doesn't on IE and Chrome.

Code:

    $("#file_upload").uploadify({
        'uploader'  : '/examples/uploadify/uploadify.swf',
        'script'    : '/examples/uploadify/uploadify-spotlight.php',
        'cancelImg' : '/examples/uploadify/cancel.png',
        'method'    : 'post',
        'debug' : true,
        'preventCaching'  : true,
        'multi'          : true,
        'fileExt'     : '*.jpg;application/jpeg;application/png',
        'fileDesc'    : 'Image Files (.JPG, .GIF, .PNG)',
        'sizeLimit'   : 62914560,
        'removeCompleted': false,
        'onSelectOnce'   : function(event,data) {
          $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
        },
        'onAllComplete'  : function(event,data) {
          //successfull
        },
        'onError' : function (event, ID, fileObject, errorObj){
             //not Successfull
        }
});

DEBUGGING: It doesn't say anything in console with chrome.


Solution

  • OK I have figured out the reason for that myself. It is due to the session. Since it is the flash communicating with the back-end script, it doesn't pass on the session variable.

    You need to do that explicity:

    $("#upload").uploadify({
      ...
      'scriptData': { 'session': '<?php echo session_id();?>'}
      ...
    });
    

    Then call the session ID in your back-end script:

    if ($_REQUEST['session']) session_id($_REQUEST['session']);