I am trying to upload the files using the HTML5 features. As per the investigation i have found that there are 3 different ways of uploading the files,
Now for cross browser issues and feature detections snippet like below is simple,
if(typeof FileReader == "undefined")
However i am not sure how to find out if send() method of the AJAX in current browser is supporting send(FormData)
or send(Blob/File)
method implementation. How to find it ? Is there is Object.property trick here ? Or something different ?
Thanks,
To handle binary data you will want to use WebSockets. This is part of the new HTML5 spec. There is a problem, though. As of mid-December, 2010, WebSockets were disabled in every major browser because of a cache-poisoning vulnerability.
Last I heard this was still being sorted out.
To upload the file before sending it via WebSockets you should use the FileReader API which is supported in the latest version of each browser (to the best of my knowledge).
To check if the FileReader is supported you should test like:
if (FileReader){
// It's supported
}
You can also check for:
if (window.URL){
//
}
for an alternative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With