- This topic is empty.
-
AuthorPosts
-
July 18, 2011 at 7:38 am #33540nchippingMember
I cannot seem to get this to work. I have tried multiple things, and all of them give me the same PHP error, that there is no such file or directory in the site. This isn’t true, because if I FTP to the site, I can SEE that these files are there… Anyway, here is what I’m doing:
unlink(str_replace(“http://www.url.com/”,””,$films));
I understand that unlink does NOT take a URL, and I store some url info in the DB, so I strip that out. So I am basically just using a straight path to the file, since I’m in the root directory of the site when doing this. So that line above would actually run as something like this:
unlink(upload/uploads/images/VZB-idea.png);
Any ideas on this? I’ve also tried doing it this way:
unlink($_SERVER . str_replace(“http://www.url.com/”,””,$films));
Again, same result – nothing I’ve done will work, and it can never ‘find’ the file, even though it’s there. Please, please help if you can. Thanks.
July 18, 2011 at 8:13 am #83543nchippingMember@TT_Mark, it doesn’t make a difference – I get the same error again :( Any other ideas?
July 18, 2011 at 8:17 pm #83585ddliuMemberMake sure you get the right path to the file.
It’s a better practice to always use ABSOLUTE path.Try to print the path and check if it does exist:
$file_path=$_SERVER . str_replace("http://www.url.com","",$films);
echo $file_path;
echo '
';
var_dump(file_exists($file_path));
BTW, it’ll be helpful if you can show your PHP error.
July 18, 2011 at 11:23 pm #83599nchippingMember@ddliu – I don’t think you read my original post – I DID try using the $_SERVER, but with no success. I have tried multiple things – the file DOES exist (it’s being used in multiple places on the site), but I want the user to have the option to delete it. The error I get says:
Warning: unlink(/home/syxbit/public_html/mysite.net/upload/uploads/images/Flip Flops.png
) [function.unlink]: No such file or directory in /home/syxbit/public_html/mysite.net/edit_videos.php on line 27
The output of:
echo $_SERVER . str_replace("http://www.mysite.net","",$films);
is exactly the path in the unlink.
Any other ideas?
July 19, 2011 at 1:21 am #83615ddliuMemberThe only thing I can guess is the file path issue.
I see there is a new line at the end of the path:
Warning: unlink(/home/syxbit/public_html/mysite.net/upload/uploads/images/Flip Flops.png
HERE IS A NEW LINE?
)
Is it exact what it is? Maybe you can try to “trim()” it to see the result.
Also something you may have a try:
1. Try a path without space.
2. Change file permission to 777 and try it again.July 19, 2011 at 8:44 am #83619 -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.