Edit:
I noticed similarly answered questions that detailed setups that were running MAMP servers on local machines. The error in this question is from error.log on a live remote LAMP server.
My app receives a json error when trying to call the upload function that is being hosted on a live LAMP remote server.  The error reads: errorJson('Upload on server problem. Please try again!');.
When checking the error.log the output reads
[24-Jul-2020 13:14:49 America/Los_Angeles] PHP Warning:  move_uploaded_file(upload/30.jpg): failed to open stream: Permission denied in /var/www/html/api.php on line 81
[24-Jul-2020 13:14:49 America/Los_Angeles] PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpQay1Tw' to 'upload/30.jpg' in /var/www/html/api.php on line 81
Here is the upload function from /var/www/html/api.php
function upload($id, $photoData, $title) {
// index.php passes as first parameter to this function $_SESSION['IdUser']
// $_SESSION['IdUser'] should contain the user id, if the user has already been authorized
// remember? you store the user id there in the login function
if (!$id) errorJson('Authorization required');
// check if there was no error during the file upload
if ($photoData['error']==0) {
    // insert the details about the photo to the "photos" table
    $result = query("INSERT INTO photos(IdUser,title) VALUES('%d','%s')", $id, $title);
    if (!$result['error']) {
        // fetch the active connection to the database (it's initialized automatically in lib.php)
        global $link;
     
        // get the last automatically generated ID in the photos table
        $IdPhoto = mysqli_insert_id($link);
     
        // move the temporarily stored file to a convenient location
        // your photo is automatically saved by PHP in a temp folder
        // you need to move it over yourself to your own "upload" folder
        //understanding > text edit cont...!
        //move_uploaded_file
        //&
        //thumb("upload/"
Line 81
        //move_uploaded_file — Moves an uploaded file to a new location
        if (move_uploaded_file($photoData['tmp_name'], "upload/".$IdPhoto.".jpg")) {
            // file moved, all good, generate thumbnail
            thumb("upload/".$IdPhoto.".jpg", 180);
            
            //just print out confirmation to the iPhone app
            print json_encode(array('successful'=>1));
        } else {
            //print out an error message to the iPhone app
            errorJson('Upload on server problem. Please try again!');
        };
    } else {
        errorJson('Hmm...Upload database problem!'.$result['error']);
    }
} else {
    errorJson('Upload malfunction');
}
} 
What we've found
move_uploaded_file failed to open stream and Permission denied error
And
move_uploaded_file gives "failed to open stream: Permission denied" error
The result is an app with blank placeholder images
I have yet to try the above. Does this look like the correct solution?
Should the errors be resolved seperatley or will allowing permissions remove both errors?



 
    