我正在尝试将单个图像从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)
错误:
'ascii' codec can't decode byte 0xff in position 475: ordinal not in range(128)