如何处理图像上传与jQuery后提交 [英] How to handle image uploads with jquery post submit

查看:170
本文介绍了如何处理图像上传与jQuery后提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTML表单,我与jQuery与以下submittng形式

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

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

但是,如果我提交表单没有Ajax则图像得到由Django的功能上传

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

推荐答案

您无法上传使用XMLHtt prequest(AJAX)的文件。但是,你可以尝试使用一些Ajax的jQuery插件上传文件

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

另外检查<一href="http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery">how-can-i-upload-files-asynchronously-with-jquery

这篇关于如何处理图像上传与jQuery后提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆