Md. Rashedul Hasan Md. Rashedul Hasan - 3 years ago 185
PHP Question

move 'tmp' directory not working when uploading image in laravel 5.4

When uploading my image it is saved to

D:\xampp\tmp\phpD0E0.tmp directory
. But I want to save it in
public/uploads/banner
. Anyone please help me. Here is my code:


BannersController.php


public function store(Request $request)
{

$requestData = $request->all();


if ($request->hasFile('banner_image')) {
foreach($request['banner_image'] as $file){
$uploadPath = public_path('/uploads/banner');

$extension = $file->getClientOriginalExtension();
$fileName = rand(11111, 99999) . '.' . $extension;

$file->move($uploadPath, $fileName);
$requestData['banner_image'] = $fileName;
}
}

Banner::create($requestData);
Session::flash('flash_message', 'Banner added!');
return redirect('Banner/banners');
}

Answer Source

Did you checked the datatype in the database table, datatype should be text or varchar,Not BLOB.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download