| | |
Deleting Uploaded Files?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2006
Posts: 12
Reputation:
Solved Threads: 0
Hi,
I hope this is a PHP issue as I miss posted earlier (sorry).
I have created a page for uploading files onto my computer from the internet using PHP.
My page creates a folder to hold the uploaded files in which can be deleted.
BUT once the uploaded file is transfered to this folder I can neither delete the upload file or folder even though they are on my computer.
If I try to delete them I get an "Access denied" message. If I try to change the permissions on them (ie chmod o+w...) I get an "Operation not permitted" message.
The folder is created with :
mkdir("/user/X/pub_html/lectures/$parent_folder/$folder_name", 0755);- it is owned by nobody (as PHP is owned by nobody) & the permissions on the folder are : drwxr-xrwx
The uploaded file is created with :
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
chmod($uploadfile, 0755);
echo '<p id="message">The file has been uploaded</p>';
} etc ..
- it is owned by nobody & the permissions on the files are : -rwxr-xr-x
Any ideas how I might solve this. I have also tried force removing the files with unix commands and using the remove folder PHP command.
Much Thanks,
Sean
I hope this is a PHP issue as I miss posted earlier (sorry).
I have created a page for uploading files onto my computer from the internet using PHP.
My page creates a folder to hold the uploaded files in which can be deleted.
BUT once the uploaded file is transfered to this folder I can neither delete the upload file or folder even though they are on my computer.
If I try to delete them I get an "Access denied" message. If I try to change the permissions on them (ie chmod o+w...) I get an "Operation not permitted" message.
The folder is created with :
mkdir("/user/X/pub_html/lectures/$parent_folder/$folder_name", 0755);- it is owned by nobody (as PHP is owned by nobody) & the permissions on the folder are : drwxr-xrwx
The uploaded file is created with :
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
chmod($uploadfile, 0755);
echo '<p id="message">The file has been uploaded</p>';
} etc ..
- it is owned by nobody & the permissions on the files are : -rwxr-xr-x
Any ideas how I might solve this. I have also tried force removing the files with unix commands and using the remove folder PHP command.
Much Thanks,
Sean
You are creating both the dir and the file with permissions 755. This means that the owner ('nobody' in this case) can execute, write, & read. Everybody else can execute and read, but not write.
Apparently, your own user account is not a super-user (root privs). To delete the files, you either need to become root, or the folder needs 777 (read, write, execute) permissions. This is because to delete files in a directory, the parent directory must have write permissions.
http://www.zzee.com/solutions/unix-permissions.shtml
Apparently, your own user account is not a super-user (root privs). To delete the files, you either need to become root, or the folder needs 777 (read, write, execute) permissions. This is because to delete files in a directory, the parent directory must have write permissions.
http://www.zzee.com/solutions/unix-permissions.shtml
![]() |
Similar Threads
- Set, View, Change, or Remove Special Permissions for Files and Folders in Windows XP (Windows tips 'n' tweaks)
- A question about deleting Temp files (Windows NT / 2000 / XP)
- domain/virtual hosts all messed up, can't see the files in FTP (Linux Servers and Apache)
- Use Java to remove a block of html from a number of files? (Java)
- how to delete ALL temp internet files, etc. (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Print Friendly
- Next Thread: Trouble installing PHP on my machine
Views: 3688 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access address ajax apache api array autoincrement beginner binary broken cakephp checkbox class cms code cron curl database date dehasher directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu method methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure support! syntax system table tutorial update updates upload url validation validator variable video web xml youtube





