[英]How to upload multiple images and store their name in database with laravel 5.1?
[英]how to upload and store 3d images in laravel
我正在使用输入文件类型
<input type="file" name="file-3D" id="file-3D>
这是我的 controller 中的代码,其中我有一个带有 model Product 的变量 $product ,我有一个名为 threeD_img 的列名
if ($request->hasFile('file-3D')) {
$threeD_image = $request->file('file-3D');
$hashedname = $threeD_image->hashName();
$threeD_image->storeAs('public/product/', $hashedname );
$product->threeD_img =$hashedname;
}
但是,当我上传文件并存储带有扩展名.gltf 的 3d 图像时,我会得到 null 值或带有一些对象的 json 文件。
如何将 3d 对象上传并存储到我的文件系统中?
我已经用 jpg、png 图像测试了代码,它工作正常。
我刚刚发现您只需要更改上传文件的方式:
Storage::disk('public')->put('assets/' . $request->file3d->getClientOriginalName(), $request->file3d->get());
上面的代码将允许您将任何类型的文件上传/保存到您的服务器,并将避免将其转换为任何奇怪的文件类型,例如.bin
、 .json
或 null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.