Jump to content
xisto Community
Sign in to follow this  
Kushika

Deleting Files With PHP is this possible?

Recommended Posts

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

... 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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.