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
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.