Super Simple AJAX File Upload

preview_player
Показать описание
Seriously, it doesn't get more simple than this.
I made a jQuery plugin that uses XHR2 and jQuery (of course) to upload files with ajax.

Gist of the plugin is here
Рекомендации по теме
Комментарии
Автор

I have been looking for ajax upload on the net and I think this is the best solution out there, Tanks bro

mikail
Автор

the gist is the link to the code, its in the description.

optikalefx
Автор

Yea, good call. I didn't account for that, but I've updated the GIST to allow multiple files. They come in php as if you did name="whatever[]" name="whatever[]".

But it stays the same for single files

optikalefx
Автор

Yea the PHP code I normall use checks an array of types, so ill show that too

optikalefx
Автор

tHANK you so much.. i had already wasted my whole day in implementing file upload plugin.but this worked in single attempt..

naukarikikhabar
Автор

Aradan tam 6 yıl geçmiş ama hala mükemmel ve modern ve ultra kısa bir kod. Thank you...

erkan
Автор

thanks, did you leave a message on the github page about openjs grid? Ive been trying to respond to issues there.

optikalefx
Автор

in input tag set atribute multiple="true", now you can select multiple files on file box for multiplefile upload in same time. Do you understand?

felipemmoura
Автор

This code doesn't care what backend you use. It will send the file data as you normally would with django.

optikalefx
Автор

Hi, what should i do if i want to send for example text inputs on the same  click?  this plugin send only files and if you want to send simple text? 

nikajavakhishvili
Автор

Great man! I used jqueryForm Plugin to do that! But your solution is real clear and nice

BryanRojasQ
Автор

Hey Alex. Is there anyway I can check for compatibility on different browsers, kind of like to tell the user "your browser does not support this, please upgrade to newer version" or something like that.

umarbabajidda
Автор

@optikalefxx for me function (prog, value) execute one time and return value 99, dont work fine, can you help?

felipemmoura
Автор

I just updated the GIST, give that a shot.

optikalefx
Автор

thanks i did it and it worked like a charm, but what about if i had multiple files ?
how to catch multiple files ?

fadio_
Автор

It was working with previos version of GIST. In php I just checking filetype and responding back with like:
echo wrong filetype'));
or
echo succefull'));

mindaugaszu
Автор

your jquery selector $("myfile") isn't selecting anything. You need a . or # in front if its a class or id.

This isn't an HTML5 thing, its an XHR2 thing. check caniuse to see if the browser you're interested in supports xhr2

optikalefx
Автор

BTW... You would know how to work with imap functions would you? That is another this I am looking for and no one has any vids on that.

arronhultquist
Автор

can you tell me how to catch the images and store them to a specific folder ?
thanks in advance man

fadio_
Автор

yea, you need to use $_FILES. var_dump($_FILES) so you can see what's in there.

optikalefx