How can I remove the file from the user if the file was successfully downloaded? I have here a download function but I don't know how to do a one time download.
HTML codes with PHP:
<?php
$result=mysql_query("SELECT * FROM school_management");
while($row=mysql_fetch_array($result))
{
?>
<div class="col-xs-6 col-md-3" style="padding-bottom: 10px;">
<div class="thumbnail">
<img src="images/ebooks/<?php echo $row['PICTURE'];?>" alt="...">
</div>
<p><center><a href="files/file.php?file=<?php echo $row['FILE_NAME'];?>" class="btn btn-xs btn-inverse" role="button" style="background-color: #2980b9;">Download</a></center></p>
</div>
<?php
}
?>
file.php
<?php
include('config.php');
$file=$_GET['file'];
echo $file;
header("Content-disposition: attachment; filename=$file");
header("Content-type: application/pdf");
header('Content-Description: File Transfer');
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
readfile("$file");
?>
My file.php can only download the file with letters in title but if the file has symbols or numbers in the title, I can't download the file. So I changed all the pdf titles for me to be able to download it. Any suggestions to make my file.php download correctly and if the user downloads the file successfully, the file will be deleted from the user's database.
Database Name: caledte1_ebook
Table Name: school_management
Table Columns: ID_NUMBER, EBOOK_FILENAME, PICTURE