Chapter 8. Case Study: Enabling Asynchronous File Uploads with Progress Indicators

You're probably wondering how you can upload files through your fancy ADS.ajaxRequest() method from Chapter 7. Well, you can't—or, I should say, you can't do exactly that. The title of this chapter is a little misleading, as you may have thought that I was implying that you'd be uploading files through the XMLHttpRequest object.

While there are no technical limitations on the XMLHttpRequest object that prevent you from using it to upload files, for very good security reasons, your web browser doesn't allow JavaScript to access local files beyond the cookie. When using form file input elements, such as this:

<input type="file" id="newFile1" name="newFile1"  accept="image/jpeg,image/png" ...

Get AdvancED DOM Scripting: Dynamic Web Design Techniques now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.