Reputation: 1632
I am using jQuery to upload an image and show a live preview. I have a form with id prescriptionform
, file input with id scaninput1
and <div>
for preview with id preview
.
jQuery code:
$('#scaninput1').live('change', function() {
$("#preview").html('');
$("#preview").html('<img src="scripts/loader.gif" alt="Uploading...."/>');
$("#prescriptionform").ajaxForm({
//alert("Hiiiiiii");
target: '#preview'
}).submit();
});
Code is running and I am uploading the image, but it's not submitting to ajaximage.php
.
My HTML code:
<form name='prescriptionform' id="prescriptionform" method='post' enctype="multipart/form-data" action='ajaximage.php'>
<div id="preview"></div>
<input type="file" id="scaninput1" />
</form>
Upvotes: 0
Views: 72
Reputation: 7133
You can't upload a file directly with an ajax form submit.
You will have to use some other technology to make this work.
How can I upload files asynchronously?
Upvotes: 0