Cyril F
Cyril F

Reputation: 1882

Load image files with AJAX?

I was wondering if it's possible to load an image (from a form with an < input type="file" /> or something else like drag-and-drop area) only with AJAX ?

I ask this question because everyone have answered : "No it's definitely impossible due to a security problem. A web browser can't access file system".

So how this website do : Mothereffing Animated Gif ?

Thanks ! :)

Upvotes: 2

Views: 346

Answers (2)

SuperMykEl
SuperMykEl

Reputation: 623

Mothereffing Animated Gif is using Backbone and this script to convert the image to base64 data url.

Upvotes: 1

WhyNotHugo
WhyNotHugo

Reputation: 9916

I googled "ajax drag and drop file", and the first result is this.

Short answer: yes, it's very much possible. You should consider, though, that drag and dropping doesn't work perfectly on every browser/enviroment, so you should still keep an alternate button just in case.

Upvotes: 1

Related Questions