Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't unlink files

Status
Not open for further replies.

draigGoch

Programmer
Feb 10, 2005
166
GB
Help!
I'm trying to use the unlink function to delete files, but it doesn't delete.

The permissions for the script are 777,
The permissions for the file deleting is 777,

What am I doing wrong????



<br><br><i><font color="#ff0000">A computer always does what you tell it to, but rarely does what you want it to.....</font></i>
 
Your description is very vague and you provided no code. How can we solve your problem with what you've given us? Are there any errors? Are you sure path to the file is correct? Please post minimum amount of code to demonstrate the problem.
 
Sorry - it was a rushed post i'm afraid.

I sorted out the problem, for some bizzare reason, I can't use absolute paths - eg

$file = /php/images/picture.jpg;

nor would the code let me try the relative:

$file = images/picture.jpg;

but it would let me use:

$file = ../php/images/picture.jpg;

Therefore going up a dir, then back again before moving on.
So when I was running my code, the $file didn't exist - I didn't receive an error message, but the unlink returned false.

Thanks for the reply anyway - I'm off to find out what's wrong with the way that I write my paths - any ideas?

A computer always does what you tell it to, but rarely does what you want it to.....
 
Well, if you're using apache, the root path is different than if you're logged into the machine. To see your root path, echo a system("pwd") or something to a web browser, and see if you are where you think you are.
 
draigGoch:
It is important to remember that PHP's filesystem functions are not contstrained to the web site's document root. PHP's filesystem functions can operate anywhere on the filesystem.

So when you specify the path to a file as "/php/images/picture.jpg", that is from the root of the filesystem, not from the root of the web site.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top