• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Allow a script to delete files

M

murfitUK

Guest
Not sure if this is the correct place to post but I hope someone can help.

My website is hosted on a Plesk 7.6 Windows server and I am having trouble changing permissions to allow a script to delete or rename files.

I am building a website and a back-end admin page to allow me to upload .jpg files. The uploading part is fine - initially got an error message about not having permission to write the file but I was able to change permission by clicking a box in the control panel (although I think it was more by lucky guess than skill).

Problem now is that I am getting error messages when trying to delete files from the sever or rename them. This is a typical error:

Warning: rename(table.jpg,chart.jpg): Permission denied in C:\Inetpub\vhosts\murfituk.com\httpdocs\testarea\pictest\index.php on line 4

The script in this case is a simple php file:
<?php
$oldname="table.jpg";
$newname="chart.jpg";
rename($oldname, $newname);
?>

This index.php file and the jpg are in the same folder.

The same error happens if I use unlink($file)

I've had a look at the permissions for index.php and the folder pictest and have tried randomly clicking various options. There are lots of options to choose from and I'm getting nowhere fast.

Can anyone offer guidance as to what I need to look at to make this work?
 
Hi, its the permissions of the folder that contains the images you need to worry about, not the permissions of the php script.

Go in to File Manager and click the permissions (padlock) icon for the folder which contains the images.

Im guessing you have already ticked Allow Read and Allow Write boxes for both Plesk IIS User and Plesk IIS WP User. If not tick them for both accounts.

Then clicked the advanced button. You will see the same two accounts at the bottom of the list with <not inherited> beside them. Tick the boxes "Delete Subfolders and Files" and "Delete" for both accounts.

This will allow you to delete the files.
 
Back
Top