我的所有用戶上傳文件目錄:如何從Laravel的資源中獲取圖像?
/resources/app/uploads/
我試圖通過完整路徑來獲得圖像:
http://localhost/resources/app/uploads/e00bdaa62492a320b78b203e2980169c.jpg
,但我得到的錯誤:
NotFoundHttpException in RouteCollection.php line 161:
我怎樣才能得到圖像通過這條路?
現在我嘗試uplaod在目錄/公/上傳文件/根:
$destinationPath = public_path(sprintf("\\uploads\\%s\\", str_random(8)));
$uploaded = Storage::put($destinationPath. $fileName, file_get_contents($file->getRealPath()));
它給我的錯誤:
Impossible to create the root directory
嘗試上傳..然後你應該能夠進行資產訪問()方法.. – Jaimin
好了,如何在'存儲指定路徑公共目錄: :將()'? – Dev
你可以在保存時使用public_path(),當檢索時使用asset()。 – Jaimin