wrathican Posted July 12, 2007 Share Posted July 12, 2007 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 Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 12, 2007 Share Posted July 12, 2007 What have the permissions for the file been set to? They might be getting in the way. Quote Link to comment Share on other sites More sharing options...
wrathican Posted July 12, 2007 Author Share Posted July 12, 2007 the perms are set to 604... the files were uploaded by the script and the script is trying to delete them, should i change the perms to 777? Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 12, 2007 Share Posted July 12, 2007 that would be preferable. You can cahgne your upload script to set the permissions to 777 so you dont have to every time. Quote Link to comment Share on other sites More sharing options...
wrathican Posted July 12, 2007 Author Share Posted July 12, 2007 oo, how how how??? i thought that could be a good idea Quote Link to comment Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 www.php.net/chmod Quote Link to comment Share on other sites More sharing options...
wrathican Posted July 12, 2007 Author Share Posted July 12, 2007 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 ) ?> 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.