2

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 ! :)

6
  • 1
    There are several jquery plugins that do that, here is a list with some: creativefan.com/10-ajax-jquery-file-uploaders By the way, I think the trick is doing the uploads in a hidden iframe. Commented Jul 3, 2012 at 21:13
  • definitely possible as I've coded it before. Currently trying to find the document it's in.. Commented Jul 3, 2012 at 21:16
  • @jeroen you dont need an iframe. Theres a way to do it using a temporary file. Commented Jul 3, 2012 at 21:17
  • The sad truth, is that the website you linked to does not work dragging from Thunar into Firefox13. Commented Jul 3, 2012 at 21:19
  • By "load" do you mean "upload"? Because if you are trying to view a file selected in a file input, I can't see where the server commutation provided by Ajax would be involved. Commented Jul 3, 2012 at 21:20

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.