Valums Ajax file Upload handle the up. file?

2019-07-24 18:49发布

问题:

Yes so I am using this, valums ajax fileupload: http://valums.com/ajax-upload/

With these settings:

function createUploader(){            
    var uploader = new qq.FileUploader({
        element: document.getElementById('file-uploader-demo1'),
        action: 'photo.php?mode=upload',
        debug: true
    });           
}

Not on photo.php?mode=upload, I tried to handle the file that are being uploaded, by

if(isset($_FILES['qqfile'])){
$filename = $_FILES['qqfile']['name'];
$imageSizeInfo = getimagesize($filename);
}

It doesnt execute this, no $_FILES isset.. ? Have i forgotten anything to add in the script settings? And i tried to remove the if statement, then it just says getimagesize error needs parameter cannot be empty.

回答1:

Valums upload script (latest version) sends file information by ajax (xhr stream) when using Firefox, Chrome or Safari). However IE6/7/8/9 does not support it and falls back to iframe support which properly sets the $_FILES array.

If you only want to use the super global $_FILES array you can use the older version of Valums script and it will perform the same across all browsers.



回答2:

there are 2 kind of methods for upload in valums script, qqUploadedFileXhr and qqUploadedFileForm. If you use example script, then you use a default one : qqUploadedFileXhr.

so, to get the files info you can use : $file_name = $_GET['qqfile']; that's it, just filename only.

but, if use the 'qqUploadedFileForm', you can get the files info :

  • $_FILES['qqfile']['name'] for filename
  • $_FILES['qqfile']['size'] for size etc