Results 1 to 1 of 1

Thread: What are HTML5 File Uploads?

  1. #1
    Join Date
    Nov 2009

    Default 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.

    The markup of our Upload Center couldn’t be simpler. We have a regular HTML5 document, which includes our stylesheet and script.js file, the Filedrop plugin and the jQuery library.

            <meta charset="utf-8" />
            <title>HTML5 File Drag and Drop Upload with jQuery and PHP | Tutorialzine Demo</title>
            <!-- Our CSS stylesheet file -->
            <link rel="stylesheet" href="assets/css/styles.css" />
            <!--[if lt IE 9]>
              <script src=""></script>
                <h1>HTML5 File Upload with jQuery and PHP</h1>
            <div id="dropbox">
                <span class="message">Drop images here to upload. <br /><i>(they will only be visible to you)</i></span>
            <!-- Including The jQuery Library -->
            <script src=""></script>
            <!-- Including the HTML5 Uploader plugin -->
            <script src="assets/js/jquery.filedrop.js"></script>
            <!-- The main script file -->
            <script src="assets/js/script.js"></script>

    Example Page

    Source Code
    Last edited by sherlyk; 04-02-2014 at 05:41 AM.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts