getting data of submitted file using jquery ajax and handling It with ModelForm

I'm going to edit an ImageField using jquery ajax,after searching I found out I should use jquery form plugin,so I think using introduced method in this article is good : http://www.laurentluce.com/posts/upload-to-django-with-progress-bar-using-ajax-and-jquery/ But I wanna get data of POST image and give it to a model form to handle It,because It take care of every thing,even when the name of file is repeated,some thing like this:
and in server side : if ('id_HeadImage' in request.FILES) and (request.FILES['id_HeadImage']): gForm=GalleryForm(request.FILES['id_HeadImage'],instance=newsInstance.gallery_ptr) if gForm.is_valid(): gForm.save() as U can see I'm going to edit ImageField of a model named `Gallery` but this way I just get the file name. How can I do this? **EDIT** this is Gallery Model: class Gallery(models.Model): HeadImage = models.ImageField(upload_to="gallery",blank=True,null=True) **EDIT** Request.FILES is empty and ajax just post file name,not data!

以上就是getting data of submitted file using jquery ajax and handling It with ModelForm的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏