mardi 26 avril 2016

Laravel/S3 file uploading works on one controller but not on another

I am building an application using Laravel 5 and AWS S3 for file storage. On my S3 bucket there are two folders: users and articles. Where I'm having trouble is with uploading to the articles folder. I am using the exact same code that works with the user bucket, yet it is not working for the articles. Below is my code within my Articles controller, which it is within a function to update the user:

//function to update an article 
public function update($id)
{

   $articleUpdate=Request::all();


  if(Input::hasfile('articlefileupload')) { 
      $file = Input::file('articlefileupload');   
      $filename = $file->getClientOriginalName();

      $s3 = \Storage::disk('s3'); 
      $filepath = '/articles/' . $id; 
      $s3->put($filepath, file_get_contents($file), 'public'); 
   } 

   $article = Articles::find($id);
   $article->update($articleUpdate); 
   return redirect('articles');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire