vendredi 11 mai 2018

Renaming Server File Error (http wrapper does not support renaming) [PHP]

On my page users can upload documents, which will be saved in a user specific folder. the directories are stored in a url: "http://localhost/folder/user/documentA_user_timestamp.ext" inside a database.

Users can also delete a file, which deletes the file's entry inside the database but i want the file to be moved to a specified archive folder. However i always get this error message when the php rename() tries to do its work: "http wrapper does not support renaming in..."

I can't seem to get my head around the error message and figure out whats the cause for it

$filepath = $_POST['file'];
$archivePath = FILESYS_DOCS_ARCHIVE . basename($filepath);

if (!file_exists(FILESYS_DOCS_ARCHIVE)){
    mkdir($archivePath, 0777);
}

$success = rename($filepath, $archivePath);

if ($success){
    echo "SUCCess";
} else {
   echo $archivePath;
}




Aucun commentaire:

Enregistrer un commentaire