untz Posted January 25, 2016 at 03:30 PM Report Share #592471 Posted January 25, 2016 at 03:30 PM boa tarde, tenho um problema em fazer o download de um ficheiro que introduzi na base de dados, mas não estou a conseguir se alguem me pudesse ajudar ficaria agradecido no ficheiro download.php tenho <?php if(isset($_GET['id'])) { include (config/config.php); // query the server for the file $id = $_GET['id_ficheiro']; $query = "SELECT Ficheiro FROM ficherio WHERE id_ficheiro = '$id'"; $result = mysql_query($query) or die(mysql_error()); // define results into variables $name=mysql_result($result,0,"Ficheiro"); $size=mysql_result($result,0,"size"); $type=mysql_result($result,0,"type"); $content=mysql_result($result,0,"content"); header("Content-disposition: attachment; filename=$Ficheiro"); header("Content-length: $size"); header("Content-type: $type"); echo $content; mysql_close(); } else{ die("No file ID given..."); } ?> e no index.php: <td><a href='index.php?mod=download&id=$row->id_ficheiro'><button class='btn btn-success'> Download </button></a></td> com isto, ao carregar no button ele faz download do ficheiro index.php, não é o pretendido, se pudessem ajudar ficaria agradecido obrigado! Link to comment Share on other sites More sharing options...
tiago.f Posted January 25, 2016 at 07:16 PM Report Share #592508 Posted January 25, 2016 at 07:16 PM duplicado https://www.portugal-a-programar.pt/topic/72717-download-de-ficheiros-em-phpmysql/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now