How to delete uploaded picture
Posted: Sun Sep 11, 2005 2:06 pm
Hi I have a program where I upload a picture for a profile here is the code it works great. What I need to know is it possible when a profile is deleted to be able to delete the picture at the same time I use a DB that has the profile as well as the pic location I know how to delete the profile but can't seem to find anything for deleting the picture.
Code: Select all
<?php
set_time_limit(0);
// Set up multiple uploads if you want
$numoffile = 1;
// Fix path of your file to be uploaded
$file_dir = "../images/vehicles/"; // folder name for uploaded file
if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['myfiles']['name'][$i];
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
$newfile1 = str_replace("..", "", $newfile);
}
}
}
if (isset($i)&&$i>0){
header("Location: ins_stock.php?fileID=".$newfile1);
exit;
}
print "<form method='post' enctype='multipart/form-data'>";
for($i=0;$i<$numoffile;$i++) {
print "<input type='file' name='myfiles[]' size='30'><br>";
}
print "<br><input type='submit' name='action' value='Upload File'>";
print "</form>";
?>