Change directory for uploading image

How can I change the directory of the uploaded images.
I want to upload it in the App/public/files folder.

My code here:

    public function update(Request $request, Organigramme $organigramme)
    $id = $organigramme->id;
    $organigramme = Organigramme::find($id);
    $organigramme->matricule = $request->input('matricule');

    if ($request->has('profile_image'))
        $image = $request->file('profile_image');
        $name = str_slug($request->input('matricule'));
        $folder = '/uploads/images/';
        $filePath = $folder . $name. '.' . $image->getClientOriginalExtension();
        $this->uploadOne($image, $folder, 'public', $name);

        $organigramme->profile_image = $filePath;
    return view( '', compact('organigramme'));

public function uploadOne(UploadedFile $uploadedFile, $folder = null, $disk = 'public', $filename = null)
    $name = !is_null($filename) ? $filename : str_random(25);

    $file = $uploadedFile->storeAs($folder, $name.'.'.$uploadedFile->getClientOriginalExtension(), $disk);

    return $file;


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

In the config/filesystems file add a new save path.For example:

  'images' => [
        'driver' => 'local',
        'root' => base_path().'/app/public/files',

In the code itself, use the following code to save:

Storage::disk(‘images’)->put($path, $image);

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x