我正在尝试将单个图像从HTML发送到django视图, 使用ajax,把图片上传到cloudinary! 它总是把我扔到编码错误下面!不知道是什么! 有人真的能帮上忙吗!**在
代码:
<input type="file" name="live" id="live-upload" />
var dataimg = new FormData();
dataimg.append('img', $('#live-upload')[0].files[0]);
$.ajax({
url: '/event/creatives/',
type: 'POST',
processData: false, // important
contentType: false, // important
dataType: 'json',
data: dataimg
});
import cloudinary
import cloudinary.uploader
import cloudinary.api
cloudinary.config(
cloud_name="name",
api_key="key",
api_secret="secret")
@login_required
def update_creatives(request):
try:
cloudinary_response = cloudinary.uploader.upload(request.FILES['img'])
except Exception as e:
print str(e)
错误:
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐