salamaslam.official's avatar

File Storing Error in public directory (where index.php located)

Hi Community,

I am facing an issue, i have a working code on my machine but when I make this live it's giving error which is as follows Symfony\Component\HttpFoundation\File\Exception\FileException: Unable to write in the "/app/public/media" directory. in file /app/vendor/symfony/http-foundation/File/File.php on line 131

here is the code that I am using to upload files

       if (!File::isDirectory($directory)) {
            File::makeDirectory($directory, 0755, true, true);
        }

        $file = $request->file('file');
        $fileName = time() . '_' . $this->cleanString($file->getClientOriginalName()); // You can customize the file name if needed
        $file->move(public_path('media'), $fileName);

This code is working fine in local machine, but not on live, I am using kinsta app for the laravel, I don't want to use the laravel storage directory but it's not working, can someone have a look

Further here is the video link (video time 2 minutes): https://drive.google.com/file/d/1OU65PXYrZaL3pJkDcpAqXfHoy8emN38s/view?usp=sharing

0 likes
1 reply

Please or to participate in this conversation.