Emanuel: Problem beim löschen von Bilddateien

Beitrag lesen

Ohne einen Code-Ausschnitt, wohl kaum.

Stimmt wohl... im wesentlichen ist es das hier:

  
<?  
//   FUNCTIONS  
function uploadPicture($filename, $filetype, $filesize, $filetmpname, $fileerror, $tmp_pic_id = ''){  
 //Dateiendung  
 $exts = explode(".", basename($filename));  
 $file_extension = strtolower($exts[sizeof($exts)-1]);  
  
 //Check Picture  
 .  
 .  
 .  
 //End Check  
  
 move_uploaded_file($filetmpname, 'images/' . $tmp_pic_id . '_temp.' . $file_extension)  
  
 //Daten in DB eintragen  
  
 return $file_extension;  
}  
  
function delPicture($pic_id){  
  
 //hole Dateiendung aus DB --> $file_extension  
 //Lösche Daten aus DB  
  
 if(file_exists('images/' . $tmp_pic_id . '_temp.' . $file_extension))  
  unlink('images/' . $tmp_pic_id . '_temp.' . $file_extension);  
  
}  
  
$tmp_pic_id = '';  
$image = '';  
  
if(isset($_FILES['pic_upload'])){  
 if(!isset($_POST['tmp_pic_id']))  
  $tmp_pic_id = createUniqueTempID();  
 else  
  $tmp_pic_id = $_POST['tmp_pic_id'];  
  
 $file_extension = '';  
  
 if($_FILES['pic_upload']['error'] != 4 && $_FILES['pic_upload']['size'] != 0)  
  $file_extension = uploadPicture($_FILES['pic_upload']['name'], $_FILES['pic_upload']['type'], $_FILES['pic_upload']['size'], $_FILES['pic_upload']['tmp_name'], $_FILES['pic_upload']['error'], $tmp_pic_id);  
  
 if($file_extension){  
  if(file_exists('images/' . $tmp_pic_id . '_temp.' . $file_extension))  
   $image = 'images/' . $tmp_pic_id . '_temp.' . $file_extension;  
 }  
  
}elseif(isset($_POST['del_tmp_picture'])){  
 if(isset($_POST['tmp_pic_id']))  
  $tmp_pic_id = $_POST['tmp_pic_id'];  
 else  
  $tmp_pic_id = 0;  
  
 delPicture($tmp_pic_id);  
  
 $image = '';  
 $tmp_pic_id = '';  
}  
?>  

  
<html>  
<body>  
<?if($image){?>  
 <img src="<?echo $image;?>" alt="Bild">  
<?}else{?>  
 <img src="images/noimage.png" alt="kein Bild">  
<?}?>  
<form action="" method="post" enctype="multipart/form-data">  
<?if($image){?>  
 <input type="checkbox" name="del_tmp_picture" onchange="submit()"> Bild nicht hinzuf&uuml;gen<br><br>  
<?}?>  
Bild: <input type="file" name="pic_upload" size="40" onchange="submit()"><br>  
<?if($tmp_pic_id){?>  
 <input type="hidden" name="tmp_pic_id" value="<?echo $tmp_pic_id?>">  
<?}?>  
</form>  
</body>  
</html>  

Vielleicht hilft das ja weiter!