downloading blobs from mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barry

    downloading blobs from mysql

    Hi

    I am having trouble downloading documents saved in a blob.

    I get the correct data from the database.
    The original size saved in the table then equals the strlen of
    the file content retrieved from the db, so I'm pretty confident
    that I do get all of the data.

    I set the following headers:

    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-type: $type");
    header("Content-length: $size");
    header("Content-Disposition: attachment; filename=$name" );

    and then I do a:

    echo($content);

    This all works fine, for small files. When I have larger file (50KB +),
    the downloads stop short, resulting in incomplete downloads.


    Why could this be happening.
    Please help I'm getting very frustrated.

    Thanks
    Barry
  • Jasen Betts

    #2
    Re: downloading blobs from mysql

    ["Followup-To:" header set to comp.lang.php.]
    On 2006-02-06, Barry <b@b.com> wrote:[color=blue]
    > Hi
    >
    > I am having trouble downloading documents saved in a blob.
    >
    > I get the correct data from the database.
    > The original size saved in the table then equals the strlen of
    > the file content retrieved from the db, so I'm pretty confident
    > that I do get all of the data.
    >
    > I set the following headers:
    >
    > header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    > header("Content-type: $type");
    > header("Content-length: $size");
    > header("Content-Disposition: attachment; filename=$name" );
    >
    > and then I do a:
    >
    > echo($content);[/color]

    hopefully a blank line first.[color=blue]
    >
    > This all works fine, for small files. When I have larger file (50KB +),
    > the downloads stop short, resulting in incomplete downloads.[/color]

    does it do this for all browsers?
    [color=blue]
    > Why could this be happening.
    > Please help I'm getting very frustrated.[/color]

    I've seen it cause by the socket being closed too soon, but that wasn't with
    PHP.


    Bye.
    Jasen

    Comment

    • Jasen Betts

      #3
      Re: downloading blobs from mysql

      On 2006-02-06, Jasen Betts <jasen@free.net .nz> wrote:[color=blue][color=green]
      >>
      >> echo($content);[/color]
      >
      > hopefully a blank line first.[/color]

      what wa I thinking? PHP takes care of that detail.

      Bye.
      Jasen

      Comment

      • Barry

        #4
        Re: downloading blobs from mysql

        Thnks for the help.
        Found the problem.
        I had to add 'b' to fopen('filename ', 'rb');
        when inserting the doc.

        Barry

        Jasen Betts wrote:[color=blue]
        > On 2006-02-06, Jasen Betts <jasen@free.net .nz> wrote:
        >[color=green][color=darkred]
        >>>echo($conten t);[/color]
        >>
        >>hopefully a blank line first.[/color]
        >
        >
        > what wa I thinking? PHP takes care of that detail.
        >
        > Bye.
        > Jasen[/color]

        Comment

        • Jim Michaels

          #5
          Re: downloading blobs from mysql


          "Barry" <b@b.com> wrote in message news:ds9pd8$q1h $1@ctb-nnrp2.saix.net. ..[color=blue]
          > Thnks for the help.
          > Found the problem.
          > I had to add 'b' to fopen('filename ', 'rb');
          > when inserting the doc.
          >
          > Barry[/color]

          Oh. Your subject line said *downloading from* MySQL. not INSERTing into
          MySQL.
          just out of curiosity, if there is an internal limit on the size of a
          string, say 64K, and I can't echo the content all at once, How would I
          handle outputting a BLOB'd large file such as a PDF?
          or is it that I just can't do it with PHP? do I use pack() somehow?

          [color=blue]
          >
          > Jasen Betts wrote:[color=green]
          >> On 2006-02-06, Jasen Betts <jasen@free.net .nz> wrote:
          >>[color=darkred]
          >>>>echo($conte nt);
          >>>
          >>>hopefully a blank line first.[/color]
          >>
          >>
          >> what wa I thinking? PHP takes care of that detail.
          >>
          >> Bye.
          >> Jasen[/color][/color]


          Comment

          • Jasen Betts

            #6
            Re: downloading blobs from mysql

            On 2006-02-14, Jim Michaels <jmichae3@nospa m.yahoo.com> wrote:[color=blue]
            >
            > "Barry" <b@b.com> wrote in message news:ds9pd8$q1h $1@ctb-nnrp2.saix.net. ..[color=green]
            >> Thnks for the help.
            >> Found the problem.
            >> I had to add 'b' to fopen('filename ', 'rb');
            >> when inserting the doc.
            >>
            >> Barry[/color]
            >
            > Oh. Your subject line said *downloading from* MySQL. not INSERTing into
            > MySQL.
            > just out of curiosity, if there is an internal limit on the size of a
            > string, say 64K, and I can't echo the content all at once, How would I
            > handle outputting a BLOB'd large file such as a PDF?
            > or is it that I just can't do it with PHP? do I use pack() somehow?[/color]

            I haven't tested it with MySQL, but PostgreSQL can handle atleast a few Megs
            in a text field. if you want that sort of detail that's what the mmanual is
            for. Download it if you find looking stuff up on-line inconvenient.

            Bye.
            Jasen

            Comment

            Working...