HTML5 File Uploads with jQuery
http://tutorialzine.com/2011/09/html5-file-upload-jquery-php/
What are HTML5 File Uploads?
Uploading files using HTML5 is actually a combination of three technologies – the new File Reader API, the also new Drag & Drop API, and the good ol’ AJAX (with the addition of binary data transfer). Here is a description of a HTML5 file upload process:
- The user drops one or more files from their file system to the browser window by dragging. Browsers that support the Drag & Drop API will fire an event, which alongside other useful information, contains a list of files that were dropped;
- Using the File Reader API, we read the files in the list as binary data, and store them in memory;
- We use the new sendAsBinary method of the XMLHttpRequest object, and send the file data to the server.
Sounds complicated? Yes, it could use some optimization. Fortunately, there are jQuery plugins that can do this for us. One of them is Filedrop, which is a wrapper around this functionality, and provides features for limiting maximum file size and specifying callback functions, which is really handy for integrating it into your web applications.
Currently file uploads work only in Firefox and Chrome, but upcoming major versions of the other browsers also include support for it. A simple fallback solution for older browsers would be to display a regular file input dialog, but we won’t be doing this today, as we will be focusing our attention on using HTML5.
So lets get started!
'프로그래밍 > Script' 카테고리의 다른 글
[jQuery] 27 Fresh and Free jQuery Plugins (0) | 2013.11.07 |
---|---|
[javascript] Knockout.js: Simpler dynamic JavaScript UIs (0) | 2013.11.07 |
[javascript] input type formatter, Patterns - 포멧 패턴 (0) | 2013.11.05 |
[jQuery] jquery 실행시 jquery~~.min.map이 없다고 에러날때. (0) | 2013.11.05 |
[javascript] Riot.js: A tiny client-side MVP framework (0) | 2013.11.05 |