I am using Valum's file uploader:
http://valums.com/ajax-upload/To upload files via PHP.
1. I would like to use the size of the file upload in the onComplete call, but I do no know how to get the size of the file just uploaded. I know how to get the fileName using this,
onComplete: function(id, fileName, responseJSON){
fileName //is the filename, but what about the file size?
}
But I do not know how to get the file name (from the JavaScript, through PHP I can but that isn't much help here).
2.
Also during the onComplete call, I would like to be able to access the list item <li>
that the file upload script creates below the upload button.
When I inspect them with fire-bug I can only see that they have a class, and not an ID.
I want to hide each one once I have complete the other stuff in my onComplete, but do not want to also hide the rest of the files in the queue.
3. When a file is being uploaded, If the file already ex开发者_高级运维ists I would like a message to pop-up and ask the user if they want to overwrite the file. I would like there to then be 3 options, one where the file is not overwritten and the upload is cancelled, one where the file is not overwritten, but the new file is uploaded and a version number is added (eg, test.txt becomes testv2.txt, similar to the default now), and three where the old file is overwritten with the new file.
I can probably figure out the PHP to this quite easily, but what I need help with is understanding how the variables are passed between the pages using json/jquery/ajax/etc.
Any help with any of these questions would be much appreciated.
php.php line 301
return array('success'=>true);
you can add your own values in here eg
return array('success'=>true,'foo'=>bar);
and retrieve them on the front
onComplete: function(id, fileName, responseJSON){
alert(responseJSON["foo"]);
}
Add an id to the list item
use onSubmit: to call an ajax request to check if the file exists
Hope this helps
echo a json from server with the data you need, then use parseJSON in OnComplete function, thats a javascript object obtained from parse the response from the server.
精彩评论