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']):
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?
this is Gallery Model:
HeadImage = models.ImageField(upload_to="gallery",blank=True,null=True)
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前端其它相关文章！