What happens? Do you get errors? Is there anything in the laravel log or server logs?
May 13, 2018
11
Level 1
laravel - upload and show image
Hi all,
I try to upload bigger image but don't work. Image smaller from 100KB can upload but bigger can not upload.
I set on server php upload_max_filesize = 32M post_max_size = 32M
but still can not upload.
Upload code:
public function upload(Request $request)
{
$last_row = DB::table('ref')->latest()->first();
$destinationPath = 'images/ref/'.$last_row->id; // upload path
if(!File::exists($destinationPath)) {
File::makeDirectory($destinationPath, $mode = 0777, true, true);
}
$insertedId =$last_row->id;
$input['image'] = time().'.'.$request->image->getClientOriginalExtension();
$request->image->move(public_path($destinationPath), $input['image']);
$input['idDor'] = $last_row->id;
$input['title'] = $request->title;
ImageGallery_referencesve::create($input);
return view('ItemCRUDref.image-gallery',compact('insertedId'));
}
I can understand why i can not upload image bigger from 100KB when i set max_filesize = 32M.
Any idea?
When I upload bigger image it use index page
public function index()
{
$images =DB::table('ref')->get();
return view('ItemCRUD.ref',compact('images'));
}
My blade.php
<form action="{{ url('ref') }}" class="form-image-upload" method="POST" enctype="multipart/form-data">
<div class="row">
<div class="col-md-5">
<strong>Prior:</strong>
{!! Form::select('title', array('Yes' => 'Yes','No' => 'No'), 'No', array('class' => 'form-control')) !!}
</div>
<div class="col-md-5">
<strong>Add:</strong>
<input type="file" name="image" class="form-control">
</div>
<div class="col-md-2">
<br/>
<button type="submit" class="btn btn-success">Upload</button>
</div>
</div>
</form>
Please or to participate in this conversation.