【发布时间】:2018-05-23 04:27:01
【问题描述】:
这是我的控制器
if( $request->hasFile('file') ) {
$image = $request->file;
$extension = $image->getClientOriginalExtension();
$filename = str_random(30).'.'.$extension;
$image_resize = Image::make($image->getRealPath());
$a = public_path().'/images/content/'.$filename;
if($a) {
return response()->json([
'location' => $a
]);
}
}
它存储img路径
../../../../../../../../Applications/MAMP/htdocs/test/public/images/content2e7KZeeBDd1WuQhy8Y48ULzJTSzFbP.jpg
如何删除所有 ../ 或如何在我尝试使用的 laravel 中设置路径
$a = asset('images/content/'.$filename);
但它存储路径../../我需要存储完整路径而不是../我该如何解决这个问题
【问题讨论】:
-
你的目标是什么路径?是大众吗?
-
为什么需要完整路径而不是相对路径?
-
我想要这个路径 Applications/MAMP/htdocs/test/public/images/content/imgname @Jonjie
-
您只需要定位到您的
public文件夹,对吗?为什么需要完整路径?