Flutter 从颤振错误401将图像上载到备份
颤振图像上传到laravel backed返回401错误。我的backed有数据库字段name、middelName和profilePic api在邮递员上运行良好,但在flutter上从画廊和照相机中拾取图像不工作我已对所有清单实施了internet权限我使用了Vpn,但出现错误401 这是颤振代码Flutter 从颤振错误401将图像上载到备份,flutter,image-upload,Flutter,Image Upload,颤振图像上传到laravel backed返回401错误。我的backed有数据库字段name、middelName和profilePic api在邮递员上运行良好,但在flutter上从画廊和照相机中拾取图像不工作我已对所有清单实施了internet权限我使用了Vpn,但出现错误401 这是颤振代码 Future uploadImage() async{ final uri =Uri.parse("https://www.compaytarining.com/api/exre
Future uploadImage() async{
final uri =Uri.parse("https://www.compaytarining.com/api/exrecise2/");
var request =http.MultipartRequest('POST',uri);
request.fields["name"]=nameController.text;
request.fields["middelName"] = mnameController.text;
var pic= await http.MultipartFile.fromPath("profilePic", _image.path);
request.files.add(pic);
var response = await request.send();
print(response.statusCode);
if(response.statusCode==200)
{
print('ImageUploaded');
}
else
{
print("Error");
}
}
画廊形象
File _image;
final picker=ImagePicker();
Future getImage() async
{
final pickedImage=await picker.getImage(source: ImageSource.gallery);
setState(() {
_image=File(pickedImage.path);
});
}
非常感谢您好,检查可能是错误,这是您返回api响应时的响应可能是您将其设置为返回401。哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇