javascript - FormData without submit button -
hi there have form upload file
$("#form").on('submit',(function(e) { e .preventdefault(); $.ajax({ url: "index2.php", type: "post", data: new formdata(this), contenttype: false, cache: false, ...
in form html:
<form id="form" action="index2.php" method="post" enctype="multipart/form-data"> <input id="uploadimage" type="file" accept="image/*" name="image" /><br/> <input id="button" type="submit" value="upload"> </form>
it works. butnow want remove button. want upload automaticly when select file.
$.ajax({ url: "index2.php", type: "post", data: new formdata("#form"), contenttype: false, ...
but not works. can please me that?
you can add drop zone (just drag , drop). @ autoupload: true.
$('.fileupload').fileupload({ datatype: 'json', url: "/somewhere.com/here", dropzone: $("#picturezone"), autoupload: true, done: function (e, data) { $("#pic").attr("src", url + data.result.name + "?" + d.gettime()); } }).on('fileuploadprogressall', function (e, data) { //do while uploading. });
Comments
Post a Comment