【发布时间】:2016-09-20 14:07:53
【问题描述】:
我正在尝试将上传的文件读取到我的系统,但我无法读取它,因为每次我这样做时都会收到此错误FileNotFoundException in Filesystem.php line 41: File does not exist at path /var/www/html/.. 我不知道我在其中做错了什么。我正在使用File::get() 方法。下面是代码。感谢您的帮助
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;
}
【问题讨论】:
-
是您的文件权限是 644,文件夹权限是 077。检查一次并且提供文件的完整路径并检查
-
你为什么要这样做?
$upload = new Upload; $content = utf8_encode(File::get($path ."/". $upload->file_name)); return $content;为什么不直接将$path返回到视图并显示它! -
如何处理word文件?我的意思是每个单词文件都会有不同的文本、字体等?
-
我的意思是显示单词或pdf文件的视图应该是什么?我有一个可以下载 excel 文件但不知道如何一起使用所有这些文件?
-
我也试过这段代码,但这只是给了我一个空白页,没有别的
$file_name = File::get($file_name); $response = Response::make($file_name, 200); $response->header('Content-Type', 'application/vnd.ms-excel); return $response; }
标签: php laravel file-upload laravel-5.2 filereader