gpt4 book ai didi

ios - 无法上传图片(React native,Laravel)

转载 作者:行者123 更新时间:2023-12-01 16:14:07 26 4
gpt4 key购买 nike

我已经尝试了一段时间,但没有成功

后端

public function createInspection(Request $request) {
$path = Storage::disk('public')->putFile('bin_images', new File($request->file('image')));
return $path;
}

客户
data.append("image", {
uri: this.state.images[0].path,
type: this.state.images[0].mime,
size: this.state.images[0].size,
name: filename
});

this.props.sendInspection(data)

服务(短)
const res = await axios.post(url, data, {
headers: {
Authorization: `Bearer ${token}`,
Accept: "application/json",
"Content-Type": "multipart/form-data"
}
});

我不确定是否与未确认的路径有关(iOS图像路径),例如路径: /private/var/mobile/Containers/Data/Application/B6FEB0FD-F9C8-4088-B15F-99D27A818C76/tmp/react-native-image-crop-picker/7BD81594-30E0-4E00-919C-4F353BBDE46F.jpg
我得到这个错误
message: "The file "" does not exist", exception: "Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException", file: "/Users/ysr/tza-project/vendor/symfony/http-foundation/File/File.php", line: 37, file: "/Users/ysr/tza-project/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php", line: 116

最佳答案

问题似乎出在您的后端,请检查documentation

您应该执行以下操作:

public function update(Request $request)
{
$path = $request->file('image')->store('images');

return $path;
}

如果您想使用 putFile,则可以使用:
$path = Storage::putFile('images', $request->file('image'));

如果需要更换磁盘,则:
$path = Storage::disk('public')->putFile('images', $request->file('image'));

关于ios - 无法上传图片(React native,Laravel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52103753/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com