Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upload finish, $_FILES empty
  • Hello,

    I'm trying to implement Uplodify into a small ad posting tool. The upload process goes absolutely fine, and finish with no errors, but no files uploaded. I tried to dump the $_FILES and $_POST and print response on onComplete, but both are empty, I went through tmp folders on the server and files are not there.

    Tried to put both php and sfw files in same directory - didn't help. No errors returned with onError, no errors in PHP and no errors with javascript, I tried Firefox, Chrome and IE7 - same result everywhere.


    I have no idea what can be the problem, if you do... please let me know.

    Thanks.
  • Some code would help...
  • $(document).ready(function() {

    var uploadLimit = 2,
    uploadCount = 0,
    uploadAlert = true,
    uploadMsg = 'Sorry but you can only upload '+uploadLimit+' pictures.';


    $(\"#fileUpload3\").fileUpload({
    'uploader': 'http://domain.com/gears/static/js/uploader.swf',
    'cancelImg': 'http://domain.com/gears/static/imgs/cancel.png',
    'script': '/gears/',
    'scriptData': {'ajax':'1', 'module':'upload'},
    'fileExt': '*.jpg;*.jpeg;*.gif;*.png;*.mp3',
    //'displayData': 'speed',
    //'simUploadLimit': 4,
    'folder': 'files',
    'fileDesc': 'Image Files',
    'multi': true,
    'auto': true,
    onCancel: function(a, b, c, d){
    uploadCount--;
    },
    onClearQueue: function(a, b){
    uploadCount = b.fileCount;
    },
    onSelect: function(a, b){
    if( uploadCount==uploadLimit ){
    if( uploadAlert ){
    alert(uploadMsg);
    uploadAlert = false;
    }
    return false;
    }
    else{
    uploadCount++;
    }
    },
    onAllComplete:function(){
    //your form function call here
    //queueSize = 0;
    alert('aa');
    },
    onComplete:function(event, queueID, fileObj, response, data){
    //queueSize--;
    alert(response);
    //alert(response);
    alert(fileObj.name);
    $('#filesUploaded').text($('#filesUploaded').text()+fileObj.name);
    },
    onError: function(a, b, c, d)
    {
    if (d.status == 404)
    alert('Could not find upload script. Use a path relative to: '+'');
    else if (d.type === \"HTTP\")
    alert('error '+d.type+\": \"+d.status);
    else if (d.type ===\"File Size\")
    alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
    else
    alert('error '+d.type+\": \"+d.text);
    }
    });
    });

    </script>

    http://domain.com - for example
    script /gears/ - if domain.com used will have IO error, so I use relative path
    I test with 17mb mp3 files


    PHP:
    var_dump($_FILES);//returns empty array
    if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = '/var/www/domain.com/gears/';
    $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

    // Uncomment the following line if you want to make the directory if it doesn't exist
    // mkdir(str_replace('//','/',$targetPath), 0755, true);

    move_uploaded_file($tempFile,$targetFile);
    }
    echo \"1\";
  • In this code no upload script is called.:

    use:

    'script': '/gears/upload.php',
  • The script is called, look:
    'script': '/gears/', 'scriptData': {'ajax':'1', 'module':'upload'},
    This means: /gears/?module=upload&ajax=1 or I can write 'script':'/gears/index.php' and it will be exactly the same thing, and I receive the empty array response (var_dump) from the PHP script through the onError function.

    I tried with /gears/upload.php and /gears/uploader.swf in same directory - but it didn't help
  • Your script is being found otherwise you would be getting a HTTP 404 error. Try implementing this post http://www.uploadify.com/forum/viewtopic.php?f=5&t=14. It's test for errors on $_FILES. If your problem is a php.ini setting it will report that error.
  • I will try, but no reason to do it :-)
    $_FILES is an empty array.


    Does anyone know how flash upload works? does it upload to PHP's or its own temporary folder on the server?
    Maybe Centos have some restrictions, if anyone knows? Google is also silent about my problem :)
  • I'm seeing similar activity while doing some debugging tonight tracking down this bug.

    Files below a couple of MB are quite fine, but when I try something like 10mb, the second I hit the "Start Upload" button, ajax then calls the upload.php script with a blank $_FILES array (no payload). Confusing so far, and simply listing symptoms below (and code) until I can figure out what's happening here:

    Scenario 1:
    * Upload file of 200 kb
    * Hit Start
    * upload.php is called at completion

    Scenario 2:
    * Upload 10mb file
    * Hit Start
    * upload.php is called instantly
    * file continues to "upload" to nowhere, then is removed or discarded

    Server Notes:
    * PHP has been configured to accept 2048M for POST payload (yep, we want files that big..)
    * Apache 2.0
    * Suhosin is present however no messages in /var/log/messages or /var/log/secure indicating that it has been trigerred
    * mod_security is not installed

    testupload.html
    <html>
    <head>
    <title>Test Upload</title>
    <link rel=\"stylesheet\" href=\"/css/uploadify.css\" type=\"text/css\" />
    <script type=\"text/javascript\" src=\"/js/jquery-1.3.2.min.js\"></script>
    <script type=\"text/javascript\" src=\"/js/jquery.uploadify.js\"></script>
    <script type=\"text/javascript\">
    $(document).ready(function() {
    $('#fileInput').fileUpload ({
    'uploader': 'images/upload/uploader.swf',
    'cancelImg': 'images/upload/cancel.png',
    'script' : 'upload.php',
    'buttonText': 'Select File',
    'auto' : false,
    'folder' : 'uploads',
    'sizeLimit' : 152476800,
    'onComplete': function(event, queueID, fileObj, response, data) {
    if(response.substring(0,5) !== \"Error\") {
    $('#downloads').append(\"<a href='https://test/download.php?fid=\" + response + \"'>Download \" + fileObj.name + \"</a>\");
    } else {
    alert(response);
    }
    }
    });
    });
    </script>
    </head>
    <body>
    <input type=\"file\" name=\"fileInput\" id=\"fileInput\" />
    <a href=\"javascript:$('#fileInput').fileUploadStart()\">Start Upload</a> | <a href=\"javascript:$('#fileInput').fileUploadClearQueue()\">Clear Queue</a>
    <p></p>
    <div id=\"downloads\"></div>
    </body>
    </html>


    upload.php
    ...post-processing and DB calls...
    // Now for the actual work
    if(empty($msg)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $fileName = $_FILES['Filedata']['name'];
    $fileType = $_FILES['Filedata']['type'];
    $fileSize = $_FILES['Filedata']['size'];
    $targetPath = TMP_LOCAL_STORAGE . $fid . '/';
    $targetFile = str_replace('//','/',$targetPath) . time() . \"_\" . $userid . \"_\" . $fileName;

    if(move_uploaded_file($tempFile, $targetFile))
    {
    ...more DB work here...
    $stringData = $fileId;
    } else {
    $stringData = \"Error: \" . intval($_FILES['Filedata']['error']) . \" Error Info: \" . $msg;
    }
    } else {
    $stringData = \"Error: 1 Error Info: \" . $msg;
    }

    $data['message'] = \"upload -> \" . $stringData;
    Log::logData($data);
    echo $stringData;
    ?>
  • I am having the same problem with larger files. Is there any news on this issue, or is this a flash limitation?
  • I see from the above example in onComplate it is appending a download link to a secure server. If you are uploading to a secure server my understanding is you need an official certificate for it to work. I don't have any SSL certificates do I have never been able to test it, but I do know it doesn't work with self generated ones.

    Try it outside the secure server and it should work as expected.