簡體   English   中英

Filesystem.php第41行中的FileNotFoundException:文件在路徑(LARAVEL)中不存在

[英]FileNotFoundException in Filesystem.php line 41: File does not exist at path (LARAVEL)

我正在嘗試將上傳的文件讀取到我的系統中,但是我無法讀取它,因為每次我這樣做時,都會FileNotFoundException in Filesystem.php line 41: File does not exist at path /var/www/html/..收到此錯誤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;
}

模型

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',
    ],

],

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM