Lumen API 在 Postman 上上传文件,在 Android Multipart 上找不到
Lumen API Upload File Work on Postman, not found on Android Multipart
我创建 api 来上传图片,它适用于邮递员,但在 Android 上使用多部分数据未找到响应。
这是我的片段
if ($request->hasFile('attachment')) {
$file = $request->file('attachment');
$filename = $file->getClientOriginalName();
$attachmentName = 'bookingfee_' . $bookingData->salesforce_id . '_' . md5($filename) . '.' . $file->getClientOriginalExtension();
$file->move('attachment/', $attachmentName);
$bf = BookingFee::find($bookingfee_id);
$bf->attachment = $attachmentName;
$bf->save();
} else {
$this->result['message'] = 'File not found';
return $this->result;
}
对此有什么线索吗?我应该向我的控制器添加一些东西吗?
在我的合作伙伴代码上,总是 return 找不到文件。
我使用 POST 方法
你应该删除 header (content-type: multipart/form-data) 如果你使用它。
我曾经遇到过这样的问题,我发现了这个 link
我创建 api 来上传图片,它适用于邮递员,但在 Android 上使用多部分数据未找到响应。
这是我的片段
if ($request->hasFile('attachment')) {
$file = $request->file('attachment');
$filename = $file->getClientOriginalName();
$attachmentName = 'bookingfee_' . $bookingData->salesforce_id . '_' . md5($filename) . '.' . $file->getClientOriginalExtension();
$file->move('attachment/', $attachmentName);
$bf = BookingFee::find($bookingfee_id);
$bf->attachment = $attachmentName;
$bf->save();
} else {
$this->result['message'] = 'File not found';
return $this->result;
}
对此有什么线索吗?我应该向我的控制器添加一些东西吗? 在我的合作伙伴代码上,总是 return 找不到文件。 我使用 POST 方法
你应该删除 header (content-type: multipart/form-data) 如果你使用它。
我曾经遇到过这样的问题,我发现了这个 link