Posting images from src to server

时间:2015-06-26 10:29:23

标签: jquery html django html5 django-views

I have a form like below, want to post image file from src of img, what should I do?

<form style="width: 205px; height: 205px; float: left;" method="post" action="/3/edit_profile/" enctype="multipart/form-data">
    <input type="hidden" name="csrfmiddlewaretoken" value="uw4rYSsp...">
    <img id="cropped_0" src="data:image/png;base64,iVBO...">
</form>

1 个答案:

答案 0 :(得分:0)

所以我认为你想将图像存储在数据库中。为此,您可以将src图像传递到django视图(使用隐藏输入)。然后在django视图

import requests
img = requests.get(src)

然后,您可以按img.content访问图像内容并将其存储在数据库中