我的所有用户上传文件目录:如何从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