javascript - Submit form using file input type -


I am using this code to upload a simple image file.

  & lt; Form action = "upload.fp" method = "post" encrypt = "multipart / form-data" & gt; & Lt; Input type = "file" name = "file" onchange = "this.form.submit ();" /> & Lt; / Form & gt;  

Then I have an upload.php file that is working very well. Now I want to use jQuery Post or Ajax to upload the image and want to show it on the screen without refreshing the page. I've changed the code for:

  & lt; Form action = "" method = "post" enctype = "multipart / form-data" & gt; & Lt; Input type = "file" name = "file" /> & Lt; / Form & gt;  

I have added it to my Javascript file:

  $ ("form # formUpload"). Submit (function () {$ .post ('Upload.php', $ ("# formUpload"). Serialize (), function (data) {}) done (function () {});});  

But nothing happens I know that I do not have the submitted input to enter the method which is the contents of the $ post. I tried with a trigger in a hidden submit button but nothing is working. Can anyone help solve it?


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -