Jump to content

[SOLVED] PHP Unlink()


wrathican

Recommended Posts

hey guys ive created an image gallery and the user can create and delete albums

ive done what i think is needed but my script doesnt delete the image. when i look at the server the image is still there. any idea why this is happening?

 

here is the code im using:

case "delepic":
		//get the album ID
		$picid = $_GET['picid'];
		//get the image name from the db
		$query = "SELECT im_image FROM cy_image WHERE im_id='" . $picid ."'";
		$result = mysql_query($result);
		while($row = mysql_fetch_row($result))
		{
		$image = $row[0];
		//delete the image
		unlink("../images/gallery/" . $image);
		}
		$query = "DELETE FROM cy_image WHERE im_id='" . $picid ."'";
		mysql_query($query);

		echo "The image has been deleted. Please go <a href='galleryadmin.php'>back</a> and make another selection.";

 

the record set is deleted from the DB so that works

Link to comment
https://forums.phpfreaks.com/topic/59645-solved-php-unlink/
Share on other sites

so some thing like this on my upload script would work?:

 

<?php
//the $randname is an md5 generation of characters and $ext is the extension
$filename = '../images/gallery/' . $randname . '.' . $ext;

//move the file to its new location and name
move_uploaded_file($tmpName, $filename);

//change file perms
chmod ($filename, 0777 )
?>

Link to comment
https://forums.phpfreaks.com/topic/59645-solved-php-unlink/#findComment-296436
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.