Jump to content

troubleshooting Download Script


eddiegster

Recommended Posts

Hello,

Put together this Download script which basically reads data from a mysql database and attempts to download the file to the user.

I believe it does make the connection to the database, but does not return any data or dialogue to the user for the user to save.

 

Am, I missing something here?  Just a Php newbie.

 

Thanks,

 

Eddie

 

<?php

if ($id_files) {

  include "open_db.inc";

  $sql = "SELECT bin_data, filetype, filename, filesize FROM tbl_Files WHERE id_files=$id_files";

 

  $result = @mysql_query($sql, $db);

  $data = @mysql_result($result, 0, "bin_data");

  $name = @mysql_result($result, 0, "filename");

  $size = @mysql_result($result, 0, "filesize");

  $type = @mysql_result($result, 0, "filetype");

 

  header("Content-type: $type");

  header("Content-length: $size");

  header("Content-Disposition: attachment; filename=$name");

  header("Content-Description: PHP Generated Data");

  echo $data;

 

Link to comment
https://forums.phpfreaks.com/topic/67633-troubleshooting-download-script/
Share on other sites

first off, i'd recommend (not just to you, but to everyone here) to seriously avoid the @ suppressor. If you have an error, the suppressor will hide it from you, making debugging 100x harder. So on the 5 lines that use it - remove it, run the script again, and post any errors you get here.

 

this has nothing to do with OOP either so moving to PHP Help...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.