F
F
freeman02042017-01-18 23:45:13
PHP
freeman0204, 2017-01-18 23:45:13

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");
      }

This is a script for uploading files to the server.
$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

1 answer(s)
E
entermix, 2017-01-18
@freeman0204

Use the unlink function to remove files from your hard drive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question