php - Laravel 4 upload image form -


i'm trying make form allows uploading file , store in public/upload folder of application.

my form is:

<form action="/image/save" method="post"> <input name="image" type="file" /> <input type="submit" value="save"/> </form> 

and controller:

public function save(){ $file = input::file('image'); $destinationpath = 'upload/'; $filename = $file->getclientoriginalname(); input::file('image')->move($destinationpath, $filename); 

but when run following error: call member function getclientoriginalname() on non-object

you need have file input enabled on form. (doc)

in laravel, can use:

form::open('image/save', array('files'=> true)) 

or

<form action="/images/save" method="post" enctype="multipart/form-data"> 

otherwise receiving file input file name string.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -