lundi 10 août 2020

Laravel 5.0 files upload validation

I'm trying to upload multiple files via postman. And would like to validate the files before uploading them. I'm using Laravel 5.0 here is my code to upload the files so far:

if ($request->hasFile('attaches')) {

  $files = $request->file('attaches'); 

  foreach ($files as $key => $file) {
    $extension = $file->getClientOriginalExtension();
    $name = time() .$key. '.' . $extension;
    $path = 'files'  . '/';
    $file = $uploadedFile->move($path, $name);
  }
}

This code uploads the files just fine but i would like to validate them before the upload as well. How can I do that in Laravel 5.0?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire