lundi 7 août 2017

Laravel: File not found exception for a 'video' file

I am creating a new Model (called Media) and by uploading a video file from the field userfile I have this error:

FileNotFoundException in Filesystem.php line 40:
File does not exist at path

my Controller

    public function store(Request $request)
   {
      // Validation //
      $validation = Validator::make($request->all(), [
         'caption'     => 'required',
         'description' => 'required',
         'category' => 'required',
         'userfile'     => 'sometimes|'
      ]);

      // Check if it fails //
      if( $validation->fails() ){
         return redirect()->back()->withInput()
                          ->with('errors', $validation->errors() );
      }

      $media = new Media;
      //dd($request);

      // upload the media //
      $file = $request->file('userfile');
      $filename = str_random(6).'_'.$file->getClientOriginalName();

      if($file){
        Storage::disk('local')->put($filename, File::get($file));
      }
      dd($file);
      $destination_path = 'uploads/';
      $file->move($destination_path, $filename);

      // save media data into database //
      $media->file = $destination_path . $filename;
      $media->caption = $request->input('caption');
      $media->category = $request->input('category');
      $media->description = $request->input('description');
      $media->save();

      return redirect('/medias')->with('message','You just uploaded an media!');
   }

line 40 correspond to Storage::disk('local')->put($filename, File::get($file));

FileSystem.php

'disks' => [

    'local' => [
        'driver' => 'local',
        'root'   => public_path('uploads'),
    ],

All my Medias model are being store on the folder public/uploads but Laravel can't find the video files on the server but if I upload a picture file it's ok?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire