3

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!

11
  • Call to a member function getRealPath() on a non-object is the key here. $fileee is not an object. You answered this yourself when you said it's an array. Commented Dec 5, 2013 at 19:16
  • @Dave no laravel docs are not wrong, i am using a package to handle photo upload intervention.olivervogel.net/image/getting_started/laravel Commented Dec 5, 2013 at 19:21
  • @Dave getRealPath() is a function of that image class i am using Commented Dec 5, 2013 at 19:22
  • 2
    Your error is self explanatory, $fileee is not an object. It has no methods. It is an array. Figure out why it's an array instead of the File object it claims it should be and you're set. Commented Dec 5, 2013 at 19:23
  • 2
    @skrilled i think this has something to do with dropzone.js, because when i upload files with normal form i do not get this error Commented Dec 5, 2013 at 19:24

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.