Home Ask Login Register

Developers Planet

Your answer is one click away!

Raghav February 2016

Laravel: Trouble with uploading filles on localhost

I've trouble getting the file upload working with Laravel on my Windows 7 system. There is no issue with uploading the files but when I see the destination directory the uploaded file is not present.

After searching in Google and forums I found that there may be a problem with the 'Temp' directory.

The output of dd(sys_get_temp_dir()) is C:\Users\RAGHAV~1\AppData\Local\Temp.

However there is no directory called RAGHAV~1(I've enabled to see the hidden folders). In php.ini the upload_tmp_dir is set to C:\xampp\tmp.

Is there any conflict between these settings? Can you please help me to get the file upload working?

The code in the controller that process the uploaded files:

$validator = $this->brandValidator($request->all());

if ($validator->fails()) {
        $request, $validator

$image_directory = public_path() . '/Uploads/Products/';

$result = $request->file('image')->move($image_directory);

$brand_name = $request->input('brand_name');
$image = $image_directory . $request->file('image')->getClientOriginalName();

$id = Brand::create([
    'brand_name' => $brand_name,
    'image' => $image,


Richie February 2016

You have not specified the path for the file. Simply replace this

$image_directory = public_path() . '/Uploads/Products/';

$result = $request->file('image')->move($image_directory);

with this

$file = $request->file('image');

$filename =  $file->getClientOriginalName().'.' . $file->getClientOriginalExtension();

$file->move(public_path('Uploads/Products/'), $filename);

Post Status

Asked in February 2016
Viewed 2,090 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life