Filesystem.php中的FileNotFoundException第41行:文件不存在路径(LARAVEL)
问题描述:
我正尝试将上传的文件读取到我的系统,但我无法读取它,因为每次我都会读取它错误FileNotFoundException in Filesystem.php line 41: File does not exist at path /var/www/html/..
我不知道我在做什么错误。我正在使用File::get()
方法。以下是代码。感谢您的帮助Filesystem.php中的FileNotFoundException第41行:文件不存在路径(LARAVEL)
public function getUploadedFile() {
$destinationPath = 'uploads';
$path= public_path()."/". $destinationPath;
echo $path; // this was to check whether am I getting the right path or not which I am getting.
$upload = new Upload;
$content = utf8_encode(File::get($path ."/". $upload->file_name));
return $content;
}
答
型号
public function setFileAttribute($file){
$this->attributes['file'] = Carbon::now()->second.$file->getClientOriginalName();
$name = Carbon::now()->second.$file->getClientOriginalName();
\Storage::disk('local')->put($name, \File::get($file));
}
fileSystems.php
'disks' => [
'local' => [
'driver' => 'local',
// 'root' => storage_path('public'),
'root' => public_path('storage'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('storage'),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
],
+1
Please add some评论和你的代码片段中的描述。 –
是你的文件权限是644和文件夹的权限077.check一次,也曾经提供完整的文件的路径和检查 –
为什么你这样做? '$ upload = new Upload; $ content = utf8_encode(File :: get($ path。“/”。$ upload-> file_name)); return $ content;' 为什么不简单地将'$ path'返回到视图并显示它! –
如何用word文件做到这一点?我的意思是每个单词文件都会有不同的文本,字体等? –