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