problem with string and path
Posted: Wed Mar 22, 2006 4:12 am
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:
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!!!!
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
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 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 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
