Wrong file permissions

Fix to unable to delete file from FTP server after uploading using PHP function move_uploaded_file.
I was struggling with this for a while, I have a PHP script to upload a file to a web space (Uploadifive library), works perfect with nice ajax and bootstrap UI, however, that script somehow prevents me from deleting file just uploaded.

This is mostly because in Windows Server, PHP function inherits the permission of the temp folder when moves files from temp folder to final destination.

Found it somewhere online ...

CodeFunctionName
What is this?

Public

Tested

Original Work
Use chmod to change file attributes after uploading

<?
if (in_arrayi($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile, $targetFile);
        chmod($targetFile, 0777); // Added 2020-12-17 to go around the fact that we cannot delete file after we uploaded it
        echo '1';
    } else {
        echo 'Invalid file type.';
    }
? >

Views 652

Downloads 252

CodeID
DB ID