The permission of fopen 644 cannot open the stream file.

the requirement is to download the remote file locally. Here is the download function. Fopen executes smoothly when I download pictures or text types. When the downloaded resource is video or audio, you will be prompted failed to open stream: Permission denied . You need to set the file permission to 755. How to solve this problem?

function download_remote_file($url , $ext,  $path = "/public/download/")
        {
            $ch = curl_init();
            curl_setopt($ch , CURLOPT_URL , $url);
            curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
            curl_setopt($ch , CURLOPT_CONNECTTIMEOUT , 30);
            $file = curl_exec($ch);
            curl_close($ch);

            $fileSource = pathinfo($url);

            if (empty($fileSource["extension"])) {
                $filename = $fileSource["filename"] . "." . $ext;
            } else {
                $filename = $fileSource["basename"];
            }

            $resource = fopen($path . $filename , "a");

            fwrite($resource , $file);
            fclose($resource);
            return $filename;
        }
Php
Mar.19,2021

then change the permission
sudo chmod-R 755 / public/download/

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35913-2bfaf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35913-2bfaf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?