MadDawgX Posted February 17, 2007 Share Posted February 17, 2007 Hey there, I've got some code to delete a file: It's basically just not working, so it won't show the file location which shows that file_exist isn't working. Though if the file is an image, it WILL display the image. So the problem is with file_exist, any help appreciated. <?php // Delete Message $Del = 0; if(isset($_GET['del'])) { $Del = $_GET['del']; } // Connect Database // ************* // Delete File if ($Del != 0) { // Check File $qCheck = "SELECT * FROM files WHERE id='$Del'"; $rCheck = mysql_query($qCheck) or die('Query failed.'.mysql_error()); if(mysql_num_rows($rCheck)==1) { // Delete File $FileLoc = mysql_result($rCheck,0,'loc'); $Filename = "/team/uploads/".$FileLoc; if (file_exists($Filename)) { echo $Filename; // DEBUG unlink($Filename); } echo "<img src='$Filename'>"; //DEBUG //$qDel = "DELETE FROM files WHERE id='$Del'"; //$rDel = mysql_query($qDel) or die('Query failed.'.mysql_error()); //header('Location: ***'); } else { //header('Location: ***'); } } else { //header('Location: ***'); } ?> Quote Link to comment Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 I had this problem a year ago when I was fixing some script if your using a windows system you have to use paths like // or \\ not just \ or / I forgot which one just try em all Quote Link to comment Share on other sites More sharing options...
corbin Posted February 17, 2007 Share Posted February 17, 2007 $Filename = "/team/uploads/".$FileLoc; That will make it <apache root (assuming apache) or maybe web root>/teams/uploads... That might be the problem... Not sure though. Quote Link to comment Share on other sites More sharing options...
The_Assistant Posted February 17, 2007 Share Posted February 17, 2007 $Filename = "/team/uploads/".$FileLoc; That will make it <apache root (assuming apache) or maybe web root>/teams/uploads... That might be the problem... Not sure though. it is a likely source of the problem. try removing the 1st forward slash from the string, making it $Filename = "team/uploads/".$FileLoc; also try giving the folder full read write permissions. on a windows system by default this should already be set but make sure that it is set as 777. same goes for unix systems. you should be able do this through your FTP program Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.