samedi 6 février 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()) {
        $this->throwValidationException(
            $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,
    ]);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire