February 28, 2012
How to upload a file using a simple jquery-ajax call
Question by Alon
I am searching for a simple client-side script to upload a file using ajax.
Searching for the web for this script only brought up a lot of plugins with multi-features. I don’t need multi-feautres – just to be able to upload it as simple as possible using ajax
Is it possible to write something simple as:
$.get('server/upload.php?file = ' + $('#uploadInput').val(), function(data) {
$('.result').html(data);
});
If it is possible – how should I write it right ($('#uploadInput').val()
won’t give me the right directory path – so what do I need to do to pass the location using Ajax).
aside from that – in order to get drag&drop for files – Is there a simple script for that or do I need to use plugin (and is there a really tiny and simple one without multi-features)