HTML5 File API size issue in Safari
I have a drag and drop upload script which works fine on chrome and firefox. However, on Safari, it has an issue with retrieving the file size. It returns 0 bytes for the file size, but strangely, it will occasionally return the correct file size. This is around 1 开发者_运维知识库out of every 10 times.
I am getting the files list via a drop event like so:
var files = event.dataTransfer.files;
alert(files[0].size);
And upon trying to use the size method, I get 0 bytes in return. Does anyone know why this is happening?
The file api is slightly different to the standard. Safari 6 will change that.
Source: http://www.thebuzzmedia.com/html5-drag-and-drop-and-file-api-tutorial/
Safari's implementation has some strange bugs, however. Occasionally, I've noticed in my own use of this feature that your first drop might stall and not go through. Adding a simple asynchronous request to a blank page prior to completing the upload seems to defeat that bug.
Guide for Safari 5: http://www.deadmarshes.com/Blog/20110413023355.html
精彩评论