![](/img/trans.png)
[英]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.