Django ajax upload image

后端 未结 1 962
天涯浪人
天涯浪人 2020-12-21 15:09

I try to upload image, using Ajax without django forms.

It not return errors. Everything it\'s ok, it save in database \"name\" and \"description\" but not save \"im

相关标签:
1条回答
  • 2020-12-21 15:28

    The issue here is with the Ajax code, you cannot directly send the image via a variable.

    To do so, you would have to create FormData and then add the file to it, an example can be found here: Send Images Via Ajax.

    Or, simply use the already existing jquery Ajax Form Plugin which does all the hard work for you.

    Your choice, hope this helps :)

    0 讨论(0)
提交回复
热议问题