Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

successdav's avatar

mkdir(): Permission denied", exception: "ErrorException",

I am working with the Vimeo API for upload videos directly from my server. Everything works fine on local development.

But on Production, It fails with a 500 error code, when I try to upload a video, here is the printed message on my network tab.

message: "mkdir(): Permission denied", exception: "ErrorException",…}
exception: "ErrorException"
file: "/var/www/stechmax.com/vendor/ankitpokhrel/tus-php/src/Cache/FileStore.php"
line: 88
message: "mkdir(): Permission denied"
trace: [{function: "handleError", class: "Illuminate\Foundation\Bootstrap\HandleExceptions", type: "->"},…]

I have tried

sudo chown -R www-data:www-data /var/www/stechmax.com/public

Also to note, I can upload other files including photos.

Thanks for your help

0 likes
6 replies
Snapey's avatar

it's failing trying to create a folder. your parent folder must have executable permission to create a new folder, eg 755 on the public folder

1 like
successdav's avatar

So please how do I go about trying to fix this?

Snapey's avatar

what folder is your code trying to create?

successdav's avatar

None. The code is not trying to create any folder. Here is the controller method

    public function store(Request $request, Course $course)
    {
        if (! auth()->user()->isAdmin()) {
            abort(403,'You do not have access to carry out this request');
        }

        $request->validate([
            'video' => 'required|mimetypes:video/avi,video/mpeg,video/mp4,video/quicktime'
        ]);

        $ext = $request->video->getClientOriginalExtension();
        $name = $course->slug .'.'.$ext;

        // Upload to Vimeo
        $videourl = $this->vimeo->upload(request()->file('video'), [
                'name' => $name,
                'privacy' => [
                    'view' => 'anybody'
                ],
            ]);

        // Get the Video Id from the response
        $videourl = explode('/',$videourl);
        $videoid = $videourl[2];

        // Update course video_path with vimeo id
        $course->update([
            'video_path' => $videoid,
        ]);
        
        return response($course->video_path, 204, []);
    }

It fails at the code block where it tries to upload to Vimeo. But then this error occurs only on the production server. On local development everything works fine

Andi1982's avatar

did you find a solution for that? i have exactly same problem, also with vimeo upload

adilrehman's avatar

Follow these steps then your error will be fixed. Go to the project folder

  1. cd vendor
  2. chmod -R 775 ankitpokhrel/
  3. chown -R www-data ankitpokhrel/

Please or to participate in this conversation.