Let's say that I want to upload 3 images a.jpeg, b.jpeg and c.jpeg
I've successfully selected the images that i want to upload. Sent them to the Controller and checked with print_f() to see if they're actually to the controller. They were.
Then when I've checked my img folder only c.jpeg were successfully uploaded while rest are not.
What is the reason of this?
// AdminController
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Http\Redirect;
use Image;
// Route
Route::post('/upload', 'AdminController@store')->name('upload');
// AdminController@store:
public function store(Request $request){
if ($request->hasfile('images')) {
foreach ($request->images as $image) {
$name = time() . '.' . $image->getClientOriginalExtension();
print_r($name."<br>"); // to see if they're actually passed.
Image::make($image)->save(public_path('img/new/'. $name));
}
}
return('done');
}
<form action="{{ route('upload') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" name="images[]" id="exampleInputFile" multiple />
</div>
{{ csrf_field() }}
<button type="submit" class="btn btn-default">Submit</button>
</form>