Skip to content
Advertisement

Tag: file-upload

Upload file with Ajax XMLHttpRequest

I am trying to send file with XMLHttpRequest with this code. I get this error: T The request was rejected because no multipart boundary was found. What am I doing wrong? Answer There is no such thing as xhr.file = file;; the file object is not supposed to be attached this way. xhr.send(file) doesn’t send the file. You have to

Client Checking file size using HTML5?

I’m trying to ride the HTML5 wave but I’m facing a small issue. Before HTML5 we were checking the file size with flash but now the trend is to avoid using flash in web apps. Is there any way to check the file size in the client side using HTML5? Answer This works. Place it inside an event listener for

JavaScript file upload size validation

Is there any way to check file size before uploading it using JavaScript? Answer Yes, you can use the File API for this. Here’s a complete example (see comments): Slightly off-topic, but: Note that client-side validation is no substitute for server-side validation. Client-side validation is purely to make it possible to provide a nicer user experience. For instance, if you

Advertisement