Laravel PHP: Uploading Image with Large file size results in 'getClientOriginalName()' being 'null' -
i'm using laravel php , have photo gallery allows user upload images album. when upload images normal file size , less 8mb, uploaded , saved photo album fine. however, when try upload images bigger 8mb, keep getting 'call member function getclientoriginalname() on null' error.
to account large images being uploaded photo gallery, edited 'nginx.conf' , 'php.ini' respectively previous line in 'nginx.conf'
client_max_body_size 8m;
was changed
client_max_body_size 25m;
and in 'php.ini', line:
upload_max_filesize = 8m
was changed to:
upload_max_filesize = 25m
after making changes in both these files, in putty ran:
sudo service nginx restart sudo service php5-fpm restart
here controller uploading new photos:
public function store() { $input = \input::all(); $validation = new validators\stone_photo; $filename = str_random(4) . \input::file('photo_path')->getclientoriginalname(); $destination = "uploads/photos/"; $upload = \input::file('photo_path')->move($destination, $filename); if( $upload == false ) { return \redirect::to('home.index') ->withinput() ->witherrors($validation->errors) ->with('message', 'could not upload picture'); } $this->stone_photo->create($input, $filename); return \redirect::route('show_stone', array('id' => $input['stone_id'])); }
so once again, photos under 8mb still uploaded fine when try upload photo 9mb or over, keep getting error 'call member function getclientoriginalname() on null' error , don't know why. appreciated.
since controller action store
i'm guessing have restfull controller , action http method post
. if that's case need make sure set set post_max_size
in php.ini
:
post_max_size = 25m
otherwise upload_max_filesize
overriden post
request value of post_max_size
(which default 8mb).
Comments
Post a Comment