- Home
- Categorie
- Coding e Sistemistica
- Coding
- cancellazione image album
-
cancellazione image album
salve sto creando un sito web per la mia azienda registrazione e login e upload image album dove vengono caricate le immagini dei vari lavori ogni cliente può caricare un suo album immagini fino a qui funziona alla grande ma non riesco a eliminare immagine la parte upload si accede con session username chiedo aiuto posto i codici
<form action="" method="post" enctype="multipart/form-data"> <input type="file" name="image"> <input type="submit" name="image" value="Upload"> <?php $servername = "******"; $username = "******"; $password = ""; $database = "*******"; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); $username = $_SESSION['username']; if(isset($_FILES['image'])){ $errors= array(); $file_name = $_FILES['image']['name']; $file_size = $_FILES['image']; $file_tmp = $_FILES['image']['tmp_name']; $file_type = $_FILES['image']['type']; $array = explode('.',$_FILES['image']['name']); $file_ext=strtolower(end($array)); // Now a variabl $extensions= array("jpeg","jpg","png"); if(in_array($file_ext,$extensions)=== false){ $errors[]="extension not allowed, please choose a JPEG or PNG file."; } if($file_size > 2097152) { $errors[]='File size must be 2 MB'; } if(empty($errors)==true) { move_uploaded_file($file_tmp,"album/".$file_name); $store=mysqli_query($conn,"INSERT INTO photos (image,username,date) VALUES ('$file_name','$username',NOW()) "); mysqli_query($conn,$store); echo "Success"; }else{ print_r($errors); echo"it failed"; } } ?> </form> </div> </div> </div> <br> <div class="row"> <div class="col-sm-12"> <div class="col mb-5"> <h5>Album foto</h5> <?php include("db.php"); $query=mysqli_query($con,"SELECT * from photos where username='".$_SESSION['username']."' ") or die(mysqli_error()); while($row=mysqli_fetch_array($query)){ $username = $row['username']; ?> <div class="img"> <img src="album/<?=$row['image']?>" class="rounded mx-auto d-block" alt="..."> <br> <h5>Data</h5> <h6><?=$row['date']?></h6> <br> <br> <center> <td class="empty" width="80"><a href="delete_photos.php<?php echo '?id='.$id; ?>" class="btn btn-danger"><i class="fa fa-trash-o"></i> Delete</a></td> </center> <br> </div> ------------------------------ Delete <?php include('db.php'); $id = $_GET['id']; $con->query("delete from photos where id = '$id'"); header('location:photos.php'); ?>
dove sbaglio???
-
risolto