从WebKitFormBoundary Django Python获取图像/文件数据

从WebKitFormBoundary Django Python获取图像/文件数据,python,django,Python,Django,request.POST['name']不起作用,但request.body将显示所有webkitformbounder。我想保留一个变量 ------WebKitFormBoundary0n4xFpxTSpVthuKP Content-Disposition: form-data; name="name" ------WebKitFormBoundary0n4xFpxTSpVthuKP Content-Disposition: form-data; name="address" 您必须使用r

request.POST['name']
不起作用,但
request.body
将显示所有
webkitformbounder
。我想保留一个变量

------WebKitFormBoundary0n4xFpxTSpVthuKP
Content-Disposition: form-data; name="name"
------WebKitFormBoundary0n4xFpxTSpVthuKP
Content-Disposition: form-data; name="address"

您必须使用request.FILES['image\u file\u name\u here']来访问单个文件。例如,如果要保存发送的文件,可以执行以下操作:

with open('image.png', 'wb+') as destination:
    for chunk in request.FILES['image_file_name_here'].chunks():
        destination.write(chunk)

您必须使用request.FILES['image\u file\u name\u here']来访问单个文件。例如,如果要保存发送的文件,可以执行以下操作:

with open('image.png', 'wb+') as destination:
    for chunk in request.FILES['image_file_name_here'].chunks():
        destination.write(chunk)

你是如何发布这些数据的?它是从哪里来的?从Angularjs来的$scope.httpfunction=function(){var allform=new FormData($(“#myform”)[0]);$http({url:/test/”,方法:“POST”,数据:allform,头:{'Content-Type':undefined},})。成功(函数(数据、状态、头、配置){$scope.responsedata=data//$scope.show=data;//将$scope.persons分配到此处,因为此处解析了承诺})。错误(函数(数据、状态、标题、配置){$scope.status=status+''+headers;});您如何发布此数据?它来自何处?来自Angularjs。$scope.httpfunction=function(){var allform=new FormData($(“#myform”)[0]);$http({url:“/test/”,方法:“POST”,数据:allform,头:{'Content-Type':undefined})。成功(函数)(数据、状态、标题、配置){$scope.responsedata=data//$scope.show=data;//将$scope.persons分配到此处,因为此处解析了承诺})。错误(函数(数据、状态、标题、配置){$scope.status=status+''+headers;});您如何发布此数据?它来自何处?来自Angularjs。$scope.httpfunction=function(){var allform=new FormData($(“#myform”)[0]);$http({url:“/test/”,方法:“POST”,数据:allform,头:{'Content-Type':undefined})。成功(函数)(数据、状态、标题、配置){$scope.responsedata=data//$scope.show=data;//将$scope.persons分配到此处,因为此处解析了承诺})。错误(函数(数据、状态、标题、配置){$scope.status=status+''+headers;});