I'm trying to save images with Dropzone.js in my Laravel 4 project.
This is my code:
$fileInput = Input::file('file');
if(Input::hasFile('file'))
{
$fileName = Hash::make($fileInput->getClientOriginalName());
$path = public_path().'/images/';
$fileType = $fileInput->guessExtension();
$fileSize = $fileInput->getClientSize()/1024;
$file = new Image;
$file->nombre = $fileName;
$file->ruta = $path;
$file->tipo = $fileType;
$file->size = $fileSize;
$file->user_id = Sentry::getUser()->id;
if($fileInput->move($path, $fileName.'.'.$fileInput->guessExtension()))
{
$file->save();
}
}
I'm obtaining the next error message:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to undefined method Intervention\\Image\\Facades\\Image::save()","file":"\/Applications\/XAMPP\/xamppfiles\/htdocs\/webs\/lara4\/edu1\/app\/controllers\/ImageController.php","line":74}}
So... my problem is that I can't save my image in my Data Base. I save the image in my server, but not in my DB. Any idea why?
Thanks!
I guess you should call the 'make' method before you actually try to save the image ...
It think it's a naming convention thing. It looks like you set up the Intervention package, and so make the Image Facade in the config/app.php file.
So you call upon a Intervention\Image::save() method which doesn't exists. Rename your Image model to Picture or something or rename the Facade.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community