| | It is posible for PHP to delete files on a server? If so, how is this possible? Just out of interest... |
| Nov 8, 2009 |
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
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?
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
But is a file I'm talking about is a PNG image, how can this file have a user 'assigned' to it?
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
... 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
Keywords : deleting, files, php
(10) Hey! How can i make my included files 100% safe. Like if I include a file witht his code.. CODE (1) I am in the process of writing a small content management system for my niche sites and need to be About uploading files through php (3) Right i have done a check for a tutorial on this as well as a question about it but php is not (4) I want to transfer files from one folder to another or an entire folder in my web space. I don't (16) Hi, You can use frontpage to preview HTML files, but how can I edit and preview PHP files offline. (4) Dear Friends I need solution to a problem. The problem is as under: I am creating certain files Variables from Included files dont work (4) Today, I came up with this strange PHP behaviour. Just wanted to know if anyone has any creating, writing, deleting files (4) Hi, Can someone please tell me how to create files and write to them in PHP. I just want to create Using wget (3) Hello. A while ago, a friend showed me this PHP code (wget) which allows you to get files from other Looking for deleting, files, php
|
![]() Deleting Files With PHP - is this possible? |
Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com