Reputation: 145
I am working on a project that needs file uploading. I have implemented Dropzone.js and Laravel Framework. I am sure I have setup everything correctly, but when I drop the files to dropzone and they finish upload I get this error
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function getRealPath() on a non-object","file":"C:\\wamp\\www\\local\\app\\controllers\\AssetsController.php","line":119}}
This is my route
Route::post('create/album','AssetsController@album');
This is my Controller
$path = "assets";
$fileee = Input::file('file');
Image::make($fileee->getRealPath())->resize(500, null, true)->save($path);
When i check with laravel if there is a file it returns NULL but when i var_dump() the Input::file() i get an array of file related data, I have searched the web and cant seem to find anything.
Thanks in advance!
Upvotes: 3
Views: 2505
Reputation: 167
I also searched for an answer but got a solution.
Dropzone has this setting:
uploadMultiple: true
If you set it to true
, it forms an array that's why you needed to do $fileee[0]
. If you allow only one image to be sent, change it to false
and you will get an object.
Upvotes: 0
Reputation: 145
I finally figured out how to fix this, this is what got it fixed this is my changed Controller
$fileee = Input::file('file');
Image::make($fileee[0]->getRealPath())->resize(540, null, true)->save('assets/example.png');
If anyone is asking where did those image manipulation methods came from this is the class iam using http://intervention.olivervogel.net/image/getting_started/laravel
Hope this helps someone in the fututre
Upvotes: 3