javascript - File upload through ajaxform not working -
i trying upload image through ajax call (& php). using ajaxform plugin but, apparently when submit form "file" input value not being passed php script. here html & js:
<form action="upload_file.php" method="post" enctype="multipart/form-data" id="select-image"> <input type="file" name="image" size="30"/> <input type="submit" name="upload" value="upload" /> </form> <script> var options = { success: showresponse // post-submit callback }; // bind form using 'ajaxform' $('#select-image').ajaxform(options); // post-submit callback function showresponse(responsetext, statustext, xhr, $form) { alert('status: ' + statustext + '\n\nresponsetext: \n' + responsetext + '\n\nthe output div should have been updated responsetext.'); } </script>
and testing upload.php contains:
<?php if(isset($_post['upload'])){ var_dump($_files); } ?>
when, submit form is:
array( [image]=> )
am doing wrong? can upload image through ajaxform plugin? suggestions please.
thanks.
try add 'cache : false' in var options.
var options = { cache : false, success: showresponse // post-submit callback };
works me.
Comments
Post a Comment