problem with string and path

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
leandro
Forum Newbie
Posts: 3
Joined: Wed Mar 22, 2006 3:55 am

problem with string and path

Post by leandro »

Hi everybody,
i got a problem tryin' to unlink a file from my apache server.

I have a list of files stored in a MySQl db from wich i obtain only the name of the files.
When in my system i try to delete the file from the filesystem i build the path to the file and try to delte it in this way:

Code: Select all

## PATH_FILE_EV is a costant defined in  a config.php file,
## it contains the value: /home/www/site/mydir (the root of the site)

## DS is the DIRECTORY_SEPARATOR defined in the config.php file

## $fileDel["path_file"] contains the name of the file i must delete
## it is the result of a query.

$fileDelB = PATH_FILE_EV.DS.$fileDel["path_file"];

## Tryin' to delete
## File exists returns "false"
## Even if a try to delete without the if statement, the  unlink finction
## returns false and it doesn't delete anything.
if(file_exists($fileDelB) && !is_dir($fileDelB))
	unlink($fileDelB);
I've printed the string $fileDelB and i obtained the correct path to the file.
I also tryied to copy and paste the result into the unlink... and it works!!!!

Code: Select all

## /home/www/site/mydir/myfile.zip is the result of a previous echo $fileDelB
## This part works, it's absurd
if(file_exists("/home/www/site/mydir/myfile.zip") && !is_dir("/home/www/site/mydir/myfile.zip"))
	unlink("/home/www/site/mydir/myfile.zip");
i've tryed also to cast: (string) $fileDelB and settype($fileDelB, "string")
i modifyed the permisison to the directory but i must tell you that a couple of rows beneath this code there's a deletion of a picture performed with the same technique and it works fine.
I've checked the permissions of the two directory (the file one and the picture one) and they are the same...

I don't know what to think.. any suggestion?
Thank you
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Please do not cross post...there really is NO NEED!

Image
Locked