programerit7's avatar

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> 
0 likes
11 replies
Cronix's avatar

What happens? Do you get errors? Is there anything in the laravel log or server logs?

programerit7's avatar

There is no any errors,the log file is empty, only redirect me to index, but in my code i use post upload??? I see it uploads to 100% and when need to save it redirect to index!!!

Cronix's avatar

anything in /storage/logs/laravel.log?

Cronix's avatar

Just to be sure the values were persisted and the right php.ini edited, try this route and go to it:

Route::get('/phpinfo', function() {
    phpinfo();
});

check values for

upload_max_filesize 
post_max_size
memory_limit
max_input_time
programerit7's avatar

upload_max_filesize 32M

post_max_size 32M

memory_limit 128M

max_input_time 60

This i got when run php route, i can not access php.ini because i post site on server where i can not access

Cronix's avatar

Does it store the image data in the database and just not store the actual image?

jcphpdev's avatar

Verify the value of LimitRequestBody directive in your httpd.conf (apache config)

Please or to participate in this conversation.