473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
Feb 6 '06 #1
5 1340
["Followup-To:" header set to comp.lang.php.]
On 2006-02-06, Barry <b@b.com> wrote:
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);
hopefully a blank line first.
This all works fine, for small files. When I have larger file (50KB +),
the downloads stop short, resulting in incomplete downloads.
does it do this for all browsers?
Why could this be happening.
Please help I'm getting very frustrated.


I've seen it cause by the socket being closed too soon, but that wasn't with
PHP.
Bye.
Jasen
Feb 7 '06 #2
On 2006-02-06, Jasen Betts <ja***@free.net.nz> wrote:

echo($content);


hopefully a blank line first.


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

Bye.
Jasen
Feb 7 '06 #3
Thnks for the help.
Found the problem.
I had to add 'b' to fopen('filename', 'rb');
when inserting the doc.

Barry

Jasen Betts wrote:
On 2006-02-06, Jasen Betts <ja***@free.net.nz> wrote:
echo($content);


hopefully a blank line first.

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

Bye.
Jasen

Feb 8 '06 #4

"Barry" <b@b.com> wrote in message news:ds**********@ctb-nnrp2.saix.net...
Thnks for the help.
Found the problem.
I had to add 'b' to fopen('filename', 'rb');
when inserting the doc.

Barry
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?


Jasen Betts wrote:
On 2006-02-06, Jasen Betts <ja***@free.net.nz> wrote:
echo($content);

hopefully a blank line first.

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

Bye.
Jasen

Feb 14 '06 #5
On 2006-02-14, Jim Michaels <jm******@nospam.yahoo.com> wrote:

"Barry" <b@b.com> wrote in message news:ds**********@ctb-nnrp2.saix.net...
Thnks for the help.
Found the problem.
I had to add 'b' to fopen('filename', 'rb');
when inserting the doc.

Barry


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?


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
Feb 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Raaijmakers, Vincent (GE Infrastructure) | last post by:
It is the first time that I use blobs in mysql. Please help me out here..... Using MSSQLdb and python 2.3.4 I was surprised to see how my information was stored in the blob. My goal is to store...
1
by: Kirby Urner | last post by:
I've been testing the Cookbook example 8.6 (2002 edition) re using cPickle to insert and retrieve BLOBs from mySQL, using Python's MySQLdb module. When I try to cPickle.loads(blob), I get an...
0
by: Chris Fowler | last post by:
I am going to start storing my MP3s into a MySQL database. Many people have reccomended that I only store filenames in the database. This will work if I plan to only run my client programs...
6
by: Marcus | last post by:
Hi all, Quick question... I am storing jpegs as blobs in a mysql table, which is fine on my live server because I am just uploading them using phpmyadmin (I am working with a small number of...
7
by: Howard Lowndes | last post by:
My situation is that I am interacting PHP 4.1.2 to PostgreSQL 7.2.2 I have no difficulty inserting and managing BLOBs into the Large Object system table, and I have a user table called images...
7
by: Nilabhra Banerjee | last post by:
Hi, I am still not sure whether the BLOBS are actually stored in the database or they have the pointer to the database for that file in the filesystem. If I remove the files (sources) for BLOBS...
2
by: Jerry LeVan | last post by:
Hi, I am just getting into large objects and bytea "stuff". I created a small db called pictures and loaded some large objects and then tried to do a restore. Here is how I got the dump. ...
2
by: Mary Lei | last post by:
I cannot update the blobs correctly with mysql. I exported 3 rows from db2 to mysql database. There are blobs in the database. db2 display the 3 rows as db2 'select cast(type_blob as...
6
by: Keith Hughitt | last post by:
Hi all, I've run into a strange error while trying to store some PNG images in a MySQL database using MySQLdb. When I try to insert smaller images (< 64kb or so) everything seems to work fine....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.