Jump to content

How to Delete Images .. (not unlink)


techiefreak05

Recommended Posts

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

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

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.