php - Download A File And Insert Values Into A Database -
<?php // force download file if(isset($_post['download'])){ $file = "images/dansyo_logo.png"; header("pragma: public"); header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("content-type: application/force-download"); header( "content-disposition: attachment; filename=".basename($file)); header( "content-description: file transfer"); @readfile($file); if(@readfile($file)){ echo'proceed'; }else{ echo'failded'; } } ?> <form method='post'> <button name='download'>download</button> </form>
i have above code want code able download file , in same time insert values database.the code functioning i'm able download file.however,nothing echoed after file has downloaded or downloading.
its not going echo since header send file browser download, if wanted kind of db
submission before header sent
$file = "images/dansyo_logo.png"; //do db update here, before header if(is_readable($file)) { // insert database } else { exit(basename($file)." not found."); } header("pragma: public"); header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("content-type: application/force-download"); header("content-disposition: attachment; filename=".basename($file)); header("content-description: file transfer"); @readfile($file); exit();
note: file_exists()
return true on directory.
Comments
Post a Comment