No ideads how i can store multiple files to my database table ?
Sep 13, 2014
17
Level 30
Dropzone save pictures in the database
This is my little upload code, all images will be uploaded to the album directory of the user.
Route::post('/upload', function () {
$input = Input::all();
$rules = array(
'file' => 'image|max:3000',
);
$validation = Validator::make($input, $rules);
if ($validation->fails())
{
return Response::make($validation->errors->first(), 400);
}
$file = Input::file('file');
$albumID = Input::get('albumID');
if($file) {
$destinationPath = public_path() . '/uploads/' . $albumID ;
$filename = $file->getClientOriginalName();
$upload_success = Input::file('file')->move($destinationPath, $filename);
if ($upload_success) {
// resizing an uploaded file
Image::make($destinationPath . $filename)->resize(100, 100)->save($destinationPath . "100x100_" . $filename);
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
}
});
So far it`s working with the upload, but how can i now save all images (path) to my database table too ?
Level 65
A Google of the error "Call to undefined method Image::save()" returned this: http://stackoverflow.com/questions/25353516/laravel-4-saving-image-with-dropzone
Try naming the alias of the facade to Img since you already have a Model named "Image".
'Img' => 'Intervention\Image\Facades\Image'
1 like
Please or to participate in this conversation.
