SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    File Download from Binary Data - certain file types don't download

    I'm having a problem with a file download script. The files are stored as binary data (blobs) in the database. The code for the download page script is below.

    The problem I'm having is rather weird - certain file types work just fine (GIF, JPG, TXT I know work, not sure which others) whilst others will not load (PDF and DOC so far, maybe others too).

    When trying to download the broken filetypes I get the file download dialog (Open/Save) - clicking either one results in "Internet Explorer cannot download file.php?id=XXX from www.**********.com".

    Any ideas? Any help is appreciated!
    PHP Code:
    <?php

    include_once("functions.php");

    include_once(
    "auth.php");

    if (
    $id) {
      
    $sql "SELECT data, type, filename, size FROM files WHERE id='$id'";
        
      
    $result mysql_query($sql);
      
    $data mysql_result($result0"data");
      
    $name mysql_result($result0"filename");
      
    $size mysql_result($result0"size");
      
    $type mysql_result($result0"type");
        
      
    header("Content-type: $type");
      
    header("Content-length: $size");
      
    header("Content-Disposition: filename=$name");
      
    header("Content-Description: PHP Generated Data");
      echo 
    $data;
    }

    ?>

  2. #2
    SitePoint Guru marcel's Avatar
    Join Date
    Nov 2000
    Posts
    920
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    try phpclasses.org

    Class has simple interface to download any file from a server without displaying the location of the file

    http://www.phpclasses.org/browse.html/package/699.html

    To download it you must subscribe to phpclasses.

    But it's worth it... GPLed and works fine.

    I started using it on our intranet today.

  3. #3
    SitePoint Guru marcel's Avatar
    Join Date
    Nov 2000
    Posts
    920
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm


    I just realized your storing the data in a database... I'm not sure that class will help you then...

  4. #4
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It won't help me in this situation, thanks though.

    I can't for the life of me figure out why certain file types are working but others are not...

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *bump*

  6. #6
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found out what the problem is! How to fix it, though, is beyond me...

    The script is on a secure server (https://) - moving it to a non-secure server fixed the script.

    Problem is, I need it to be secure...

    Any ideas, or is this something for the advanced forum?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •