techiefreak05 Posted December 3, 2006 Share Posted December 3, 2006 I have a photo system on my site. users can upload images and have people comment them .. and when people upload images the URL of the image is stored in a database, and i have a button to delete the image, it removes the img data from the database, but it still is on the server, i want to ACTUALLY delete the file, as to save space.how can i do this??thanks for your time Link to comment https://forums.phpfreaks.com/topic/29278-how-to-delete-images-not-unlink/ Share on other sites More sharing options...
keeB Posted December 3, 2006 Share Posted December 3, 2006 Hmm... this is tricky. Why don't you want to use unlink? Link to comment https://forums.phpfreaks.com/topic/29278-how-to-delete-images-not-unlink/#findComment-134197 Share on other sites More sharing options...
techiefreak05 Posted December 3, 2006 Author Share Posted December 3, 2006 Well would unlink actually delete the file ?? well i tried but it doesnt work ..heres what i had:<?php$myFile = $imgPath;$fh = fopen($myFile, 'w') or die("can't open file");fclose($fh);?>$imgPath is a fetched array from a database ... <?php$sql = "SELECT * FROM `images` WHERE `userid` = '$_SESSION[id]'";$query=mysql_query($sql);while($row=mysql_fetch_array($query)){$userID=$row['userid'];$imgID=$row['id'];$imgPATH=$row['imgPath'];$headline=$row['headline'];?>and when i try to unlink .. it displays "Can't open file." Link to comment https://forums.phpfreaks.com/topic/29278-how-to-delete-images-not-unlink/#findComment-134198 Share on other sites More sharing options...
trq Posted December 3, 2006 Share Posted December 3, 2006 I dont see where you use unlink in the above code. If $imgPath holds the path to the file....[code=php:0]unlink($imgPath);[/code] Link to comment https://forums.phpfreaks.com/topic/29278-how-to-delete-images-not-unlink/#findComment-134242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.