jQuery Uploads a file, and then submits the form normally -
i hope can make sense of question.
i using jquery form plugin + validation works great.
but trying accomplish is,
1, upload temp-file manipulating in next step
2, once file has been uploaded, submit form go next step (a new file).
so i'm 100% sure how accomplish that, use code.
$("#fileupload").validate({ submithandler: function(form) { $(form).ajaxsubmit({ beforesubmit: function() { $('input').attr("disabled", true); $("#uploadresponse").show('slow'); $('#uploadresponse').append("<img src='images/icons/ajax-loader.gif' />"); }, success: function(responsetext, statustext, xhr, form) { $('input[type=submit]').attr("disabled", false); $('input[type=file]').attr("disabled", true); }, error: function (responsetext, statustext, xhr, form) { alert("oops... looks there has been problem."); } }); } });
and form
<div id="uploadresponse" style="display: none;"> file uploading, can take few minutes... </div> <form action='page.importcontacts2.php' name="mergecsv" id="fileupload" method="post" enctype="multipart/form-data" > file: <input id="getcsv" name="getcsv" class="required" type="file"> delimiter type: <select id="delimiter" name="delimiter"> <option value="1" selected="selected">comma</option> <option value="2">tab</option> </select> enclosure type: <select id="enclosure" name="enclosure"> <option value="1" selected="selected">double quotes (")</option> <option value="2">single quotes (\')</option> </select> <button type="submit" name="submitcsv" id="submitcsv" value="submitcsv" class="csvcol3button buttonsmall">upload file</button> </form>
simple answer: can't upload files through ajax. you'll have submit form page , go there.
more: technically can, not this. involves creating iframe , submitting files through that. either way, have have post back, can't use xmlhttprequest object.
if quick google search, can find plug-ins you.
Comments
Post a Comment