Multiple Image upload system
Hi. Who can send the image upload system examples for laravel 5, with validation.
Basic PHP here. Do a loop to read the images from $_FILES[''] and do validation on each.
This is a really basic example but it should get you on your way ;)
$files = Input::file('images');
foreach ($files as $file) {
// Validate each file
$rules = array('file' => 'required'); // 'required|mimes:png,gif,jpeg,txt,pdf,doc'
$validator = Validator::make(array('file'=> $file), $rules);
if($validator->passes()) {
$destinationPath = 'uploads';
$filename = $file->getClientOriginalName();
$upload_success = $file->move($destinationPath, $filename);
// Flash a message and return the user back to a page...
} else {
// redirect back with errors.
return Redirect::to('upload')->withInput()->withErrors($validator);
}
}
You can figure that out for yourself for sure ;) Give it a try and let us know what you tried and what isn't working
Please or to participate in this conversation.