How to handle image uploads with jquery post submit

邮差的信 提交于 2019-12-22 13:58:27

问题


I have the html form and i am submittng the form with jquery with following

var queryString = $('.form1').formSerialize(); 
 $.post('book/create/', queryString); 

But if i submit form without ajax then image gets uploaded by django function

Now the problem is , it is ignoring the file fields. what should i do


回答1:


You cannot upload files using XMLHttpRequest (AJAX).But you can try using some of the Ajax JQuery plugins to upload files

  • http://www.phpletter.com/Demo/AjaxFileUpload-Demo/
  • http://www.webtoolkit.info/ajax-file-upload.html

Also Check how-can-i-upload-files-asynchronously-with-jquery



来源:https://stackoverflow.com/questions/6592432/how-to-handle-image-uploads-with-jquery-post-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!