Jump to content

File exist problem


MadDawgX

Recommended Posts

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: ***');
}
?>

 

Link to comment
Share on other sites

$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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.