在 public_path 之外为 Laravel 中的文件上传放置什么 $destinationPath
What to put for the $destinationPath when outside the public_path for a file upload in Laravel
我正在尝试添加通过 Laravel 表单上传照片的功能。但是,我似乎有点超出了配置它的正常用例。
我的 laravel
目录实际上在我的主 Web 目录之外,对于某些 URI,它使用 Apache mod_alias
将其重定向以使用 Laravel 框架。我所有的 css、js 和图像都存在于主 Web 目录中,而我所有的 laravel 文件和目录都存在于其自己的单独目录中。话虽如此,我希望能够上传照片的位置是
/html/images/profile-photos
而我的 laravel 应用位于
/laravel/...
在我的表单控制器中,我有
$photo = Input::file('photo');
if ($photo->isValid()) {
$destinationPath = '/html/images/profile-photos/';
$filename = $user->id; //There might be a separate error in not including the file extension here?
$photo->move($destinationPath, $filename);
}
但是当我尝试使用表单上传图片时,出现错误
Unable to create the "/html/images/profile-photos/" directory
从外观上看,它可能不会转到实际的 /html
目录,但可能仍停留在 /laravel
目录中。有没有办法将其存储在预期位置?
抱歉。我一发布这个问题,我就意识到我的根目录实际上倒退了一步。必须是
'/root/html/images/profile-pictures'
你说它坏了,它会自己修...
我正在尝试添加通过 Laravel 表单上传照片的功能。但是,我似乎有点超出了配置它的正常用例。
我的 laravel
目录实际上在我的主 Web 目录之外,对于某些 URI,它使用 Apache mod_alias
将其重定向以使用 Laravel 框架。我所有的 css、js 和图像都存在于主 Web 目录中,而我所有的 laravel 文件和目录都存在于其自己的单独目录中。话虽如此,我希望能够上传照片的位置是
/html/images/profile-photos
而我的 laravel 应用位于
/laravel/...
在我的表单控制器中,我有
$photo = Input::file('photo');
if ($photo->isValid()) {
$destinationPath = '/html/images/profile-photos/';
$filename = $user->id; //There might be a separate error in not including the file extension here?
$photo->move($destinationPath, $filename);
}
但是当我尝试使用表单上传图片时,出现错误
Unable to create the "/html/images/profile-photos/" directory
从外观上看,它可能不会转到实际的 /html
目录,但可能仍停留在 /laravel
目录中。有没有办法将其存储在预期位置?
抱歉。我一发布这个问题,我就意识到我的根目录实际上倒退了一步。必须是
'/root/html/images/profile-pictures'
你说它坏了,它会自己修...