O'Reilly logo

AdvancED DOM Scripting: Dynamic Web Design Techniques by Aaron Gustafson, Jeffrey Sambells

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required