Script Host
Script Host

Reputation: 922

Save Url of image to database and get image

Any Help will be appreciated.

Upvotes: 0

Views: 1320

Answers (1)

Jaymin
Jaymin

Reputation: 1661

I am expecting that you have included namespace, if not

use DB;

$full_path = public_path('img/banner');
$ext = request()->image->getClientOriginalExtension();
$size = request()->image->getSize();
DB::table('uploads')->insert(
    ['group_id' => '1', user_id' => '1', 'filename' => $imageName,'filesize'=>$size ,'extension'=> $ext,'location' => $full_path,'created_at'=> date('Y-m-d H:m:s')]
);

You can get by this your database values, $imagename is the name you used to upload the image, not sure about your group_id so set to 1.

latest Edit

this is how you can get imageName:

$imageName = time().'.'.request()->image->getClientOriginalExtension();

froom your code only

Upvotes: 1

Related Questions