0

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>
0

1 Answer 1

-1

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?

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

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.