Answer the question
In order to leave comments, you need to log in
How to delete files not just from the database, but from the server too?
How to delete files not just from the database, but from the server too?
This script deletes the file.
if(isset($_POST['del_prodyct'])){
$id=$_POST['id_prod'];
$querydelete_category = "DELETE FROM add_photos_store WHERE id=$id";
$result = mysql_query($querydelete_category);
header("Location: /admin/admin.php?page=add_photos_store");
}
$query1 = "SELECT max(id) from stores";
$result = mysql_query($query1);
$line = mysql_fetch_array($result);
$max = $line['max(id)'];
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
$kod=uniqid();
move_uploaded_file($tmp_name, "images/catalog_gallery/".$kod.$name);
img_resize("images/catalog_gallery/".$kod.$name, "images/catalog_gallery/prew/".$kod.$name, $params);
$imgmedia="images/catalog_gallery/".$kod.$name;
$imgmediaprew="images/catalog_gallery/prew/".$kod.$name;
$queryup = "UPDATE stores SET url_img = '{$imgmedia}', prew_img = '{$imgmediaprew}' WHERE id = $max";
$result = mysql_query($queryup);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question