|
|
|
|
![]() ![]() |
Mar 12 2006, 11:25 AM
Post
#1
|
|
|
Member [ Level 2 ] Group: Members Posts: 72 Joined: 3-February 06 From: UK Member No.: 11,052 |
It is posible for PHP to delete files on a server? If so, how is this possible? Just out of interest...
|
|
|
|
Mar 12 2006, 11:32 AM
Post
#2
|
|
|
BUG.SWAT.PATROL Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
To delete files, you use the unlink() function.
Problems you may encounter is the owner of the file is not the script that is calling the unlink, usually if you create the file with the script and then remove it with the script, it would be ok to do so. Another problem is trying to delete a file that's in use, if that's the case, you should always make sure that you've fclose() the file before trying to remove it. Cheers, MC |
|
|
|
Mar 12 2006, 11:38 AM
Post
#3
|
|
|
Member [ Level 2 ] Group: Members Posts: 72 Joined: 3-February 06 From: UK Member No.: 11,052 |
Thanks for your help!
but let's say if I were to give global permissions via CHMODing the file (like 777), would I still be able to delete it even if the script did not create it? |
|
|
|
Mar 12 2006, 11:51 AM
Post
#4
|
|
|
BUG.SWAT.PATROL Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
If that was the case, then it's quite possible, but only a super user or the owner of the file could make those alterations to it.
Cheers, MC |
|
|
|
Mar 12 2006, 12:09 PM
Post
#5
|
|
|
Member [ Level 2 ] Group: Members Posts: 72 Joined: 3-February 06 From: UK Member No.: 11,052 |
But is a file I'm talking about is a PNG image, how can this file have a user 'assigned' to it?
|
|
|
|
Mar 12 2006, 12:42 PM
Post
#6
|
|
|
BUG.SWAT.PATROL Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
But is a file I'm talking about is a PNG image, how can this file have a user 'assigned' to it? All files are owned by someone and belong to a group, usually when you upload a file via FTP, that user who's logged in, will be the owner of that file. Also on your filesystem, you would have the owner of that file, usually an image has permissions 644, which is Owner:read/write Group:read All Others:read. So only the Owner is allowed to make alterations, all the rest can still view the file with no problems. If you created the image from your graphics program, then you're the owner of it (the person you logged in as). Only super users or yourself may alter the file, all others will only be able to read it. It also depends on where you store the photo, if it's in your home directory and you've made your home directory only viewable by the owner (you) then no one but you or super user could get to it, all the rest would be stopped trying to get into your home directory. You've obviously heard of chmod, other commands are chgrp (change group) and chown (change owner) which all these commands relate to one another in some way. Cheers, MC |
|
|
|
Mar 17 2006, 08:04 PM
Post
#7
|
|
|
Member [ Level 1 ] Group: Members Posts: 42 Joined: 17-March 06 From: Russia, St.Petersburg Member No.: 12,058 |
... all others will only be able to read it ... You've missed that Supervisors or the ones, whose authorites are higher then the one's who'd created or chmod of that file alows him to work write it, he may also whatever he wants with yhat file, despite gid are different. |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 5th September 2008 - 08:39 AM |