473,624 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem downloading binary data

Hi all

I have this script(download .php) which downloads binary data from a
mysql database.

<?

/* SNIP */

$document=docum ent::singleton( );
$doc=$document->get_document($ id);

if (is_object($doc )){
die;
}

header("Content-type: $doc[type]");
header("Content-length: $doc[size]");
header("Content-Disposition: attachment; filename=$doc[name]");

echo($doc['content']);

exit;

?>

This is called from another page in the
<a href="download. php?id=4">CLick here to download</a>
fashion.

The problem I am experiencing is that the download stop on 64k and then
the files are obviously corrupted.

I have checked that I do have the correct size in the db and I am giving
the correct size in the Content-length header.

Thanks
Barry
Jan 25 '06 #1
6 1598
Barry wrote:
Hi all

I have this script(download .php) which downloads binary data from a
mysql database.

<?

/* SNIP */

$document=docum ent::singleton( );
$doc=$document->get_document($ id);

if (is_object($doc )){
die;
}
So if $doc is an object you die?

Is that what you want?
I would expect:
if (is_object($doc )){
echo "\doc is not an object!";
exit;
}

Regards,
Erwin Moller

header("Content-type: $doc[type]");
header("Content-length: $doc[size]");
header("Content-Disposition: attachment; filename=$doc[name]");

echo($doc['content']);

exit;

?>

This is called from another page in the
<a href="download. php?id=4">CLick here to download</a>
fashion.

The problem I am experiencing is that the download stop on 64k and then
the files are obviously corrupted.

I have checked that I do have the correct size in the db and I am giving
the correct size in the Content-length header.

Thanks
Barry


Jan 25 '06 #2
>
if (is_object($doc )){
Now I make the same mistake:
Should be of course:
if (!is_object($do c)){
echo "\doc is not an object!";
exit;
} echo "\doc is not an object!";
exit;
}

Regards,
Erwin Moller

Jan 25 '06 #3
Erwin Moller wrote:
Barry wrote:

Hi all

I have this script(download .php) which downloads binary data from a
mysql database.

<?

/* SNIP */

$document=doc ument::singleto n();
$doc=$documen t->get_document($ id);

if (is_object($doc )){
die;
}

So if $doc is an object you die?

Is that what you want?
I would expect:
if (is_object($doc )){
echo "\doc is not an object!";
exit;
}

Regards,
Erwin Moller


Yes I want it to die.
The function returns an error object if it fails.
This means that an error has occured and then I just die.

If the function returns an array, its found the data.

This all works for files less than 64k.
Its only with larger files that the download stops at 64k.
This is weird bahavior, I think it might be some config on the server.

Thanks
Barry
header("Conte nt-type: $doc[type]");
header("Conte nt-length: $doc[size]");
header("Conte nt-Disposition: attachment; filename=$doc[name]");

echo($doc['content']);

exit;

?>

This is called from another page in the
<a href="download. php?id=4">CLick here to download</a>
fashion.

The problem I am experiencing is that the download stop on 64k and then
the files are obviously corrupted.

I have checked that I do have the correct size in the db and I am giving
the correct size in the Content-length header.

Thanks
Barry


Jan 25 '06 #4
Barry wrote:
Erwin Moller wrote:
Barry wrote:

Hi all

I have this script(download .php) which downloads binary data from a
mysql database.

<?

/* SNIP */

$document=do cument::singlet on();
$doc=$docume nt->get_document($ id);

if (is_object($doc )){
die;
}

So if $doc is an object you die?

Is that what you want?
I would expect:
if (is_object($doc )){
echo "\doc is not an object!";
exit;
}

Regards,
Erwin Moller


Yes I want it to die.
The function returns an error object if it fails.
This means that an error has occured and then I just die.

If the function returns an array, its found the data.

This all works for files less than 64k.
Its only with larger files that the download stops at 64k.
This is weird bahavior, I think it might be some config on the server.


Hmm, ok.

Strange.
Are you sure your document-singleton is actually delivering the right stuff?
I mean: the problem could arise earlier than at the moment of delivery.
And 64K sounds very suspect.

I would check that part first, just spit out :

echo htmlentities($d oc['content']);

Well, that is all I can think of.

Good luck.

Regards,
Erwin Moller

Thanks
Barry
header("Cont ent-type: $doc[type]");
header("Cont ent-length: $doc[size]");
header("Cont ent-Disposition: attachment; filename=$doc[name]");

echo($doc['content']);

exit;

?>

This is called from another page in the
<a href="download. php?id=4">CLick here to download</a>
fashion.

The problem I am experiencing is that the download stop on 64k and then
the files are obviously corrupted.

I have checked that I do have the correct size in the db and I am giving
the correct size in the Content-length header.

Thanks
Barry



Jan 25 '06 #5
Erwin Moller wrote:
Barry wrote:

Erwin Moller wrote:
Barry wrote:

Hi all

I have this script(download .php) which downloads binary data from a
mysql database.

<?

/* SNIP */

$document=d ocument::single ton();
$doc=$docum ent->get_document($ id);

if (is_object($doc )){
die;
}
So if $doc is an object you die?

Is that what you want?
I would expect:
if (is_object($doc )){
echo "\doc is not an object!";
exit;
}

Regards,
Erwin Moller


Yes I want it to die.
The function returns an error object if it fails.
This means that an error has occured and then I just die.

If the function returns an array, its found the data.

This all works for files less than 64k.
Its only with larger files that the download stops at 64k.
This is weird bahavior, I think it might be some config on the server.

Hmm, ok.

Strange.
Are you sure your document-singleton is actually delivering the right stuff?
I mean: the problem could arise earlier than at the moment of delivery.
And 64K sounds very suspect.

I would check that part first, just spit out :

echo htmlentities($d oc['content']);

Well, that is all I can think of.

Good luck.

Regards,
Erwin Moller


thanks for the help.
yes, I get the correct data.
when I dump the array all is there.

also, docs and images below 64k work fine.

strange one this.
Thanks
Barry

header("Con tent-type: $doc[type]");
header("Con tent-length: $doc[size]");
header("Con tent-Disposition: attachment; filename=$doc[name]");

echo($doc['content']);

exit;

?>

This is called from another page in the
<a href="download. php?id=4">CLick here to download</a>
fashion.

The problem I am experiencing is that the download stop on 64k and then
the files are obviously corrupted.

I have checked that I do have the correct size in the db and I am giving
the correct size in the Content-length header.

Thanks
Barry

Jan 25 '06 #6
I have seen cutoff problems in other posts in trying to use fread() with
chunks larger than about 8K.
is that what you are using in your method?

"Barry" <b@b.com> wrote in message news:dr******** **@ctb-nnrp2.saix.net. ..
Erwin Moller wrote:
Barry wrote:

Erwin Moller wrote:

Barry wrote:

>Hi all
>
>I have this script(download .php) which downloads binary data from a
>mysql database.
>
><?
>
>/* SNIP */
>
>$document= document::singl eton();
>$doc=$docu ment->get_document($ id);
>
>if (is_object($doc )){
>die;
>}
So if $doc is an object you die?

Is that what you want?
I would expect:
if (is_object($doc )){
echo "\doc is not an object!";
exit;
}

Regards,
Erwin Moller

Yes I want it to die.
The function returns an error object if it fails.
This means that an error has occured and then I just die.

If the function returns an array, its found the data.

This all works for files less than 64k.
Its only with larger files that the download stops at 64k.
This is weird bahavior, I think it might be some config on the server.

Hmm, ok.

Strange.
Are you sure your document-singleton is actually delivering the right
stuff?
I mean: the problem could arise earlier than at the moment of delivery.
And 64K sounds very suspect.

I would check that part first, just spit out :

echo htmlentities($d oc['content']);

Well, that is all I can think of.

Good luck.

Regards,
Erwin Moller


thanks for the help.
yes, I get the correct data.
when I dump the array all is there.

also, docs and images below 64k work fine.

strange one this.
Thanks
Barry
>header("Co ntent-type: $doc[type]");
>header("Co ntent-length: $doc[size]");
>header("Co ntent-Disposition: attachment; filename=$doc[name]");
>
>echo($do c['content']);
>
>exit;
>
>?>
>
>This is called from another page in the
><a href="download. php?id=4">CLick here to download</a>
>fashion.
>
>The problem I am experiencing is that the download stop on 64k and then
>the files are obviously corrupted.
>
>I have checked that I do have the correct size in the db and I am
>giving
>the correct size in the Content-length header.
>
>Thanks
>Barry

Feb 12 '06 #7

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

Similar topics

2
5122
by: Kubaton Lover | last post by:
I'm still having a problem with the following code, but I can better describe the symptoms now. Code: <?php $uri = getenv('REQUEST_URI'); $pieces = explode('/',$uri); $file = $pieces;
1
1371
by: NewFilmFan | last post by:
I use Python 2.3 on Windows XP. I wrote this program: import httplib conn = httplib.HTTPConnection("www.x.net") conn.request("GET", "/x/y.jpg") r1 = conn.getresponse() print r1.status, r1.reason data = r1.read() datei = open('test.jpg','w')
6
519
by: | last post by:
I am rewriting a C++ application in C#. This file has a combination of Text and Binary data. I used CFile before to read the text. If I hit a certain string that denotes the following data is binary, I used the current position in the file and another stream to read to the binary data. All text data is ended with a carriage return / line feed while the binary is actually an image file listed byte by byte. Preceding the binary data...
11
6616
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to transfer data across.On the serve I am using Socket 2 API (recv function to read bytes)and not using ..NET. I use FileStream to open the file on the pocket pc, then associate a BinaryReader object with the stream and call ReadBytes to read all the...
3
2122
by: John R. Delaney | last post by:
I am running in debugging mode after a clean C++ compilation under .NET 2003. In a BIG loop (controlled many levels up in the call stack), I open a file with fopen using the "a" option. Then I write 23 doubles to it with fwrite, one call for each double. Then I close the file using fclose. After three times around the loop in the debugger, I stop the program (using "Stop debugging"). That is writing 552 bytes. The resulting file's properties...
1
2059
by: alex23 | last post by:
Hey everyone, I'm trying to install setuptools on a work PC behind an NTLM firewall. I've tried to use APS as recommended but am still unable to have anything other than IE talk through firewall. But as I can downloaded eggs manually, I'm not overly concerned at this point. So I've tried following the instructions for un-networked installs: I've downloaded ez_setup.py and setuptools-0.6c3-py2.4.egg, putting the egg file in the same...
15
4136
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello folks, I need some help/advice FAST. I have problems with addslashes on my web-servers. After uploading a file, I read the uploaded file, use addslashes on the read data and then insert it into a blob field in a MySQL database. The problem is that this works fine on my internal test web-server (running under RedHat 7.3). But on my production web-server (running Fedora Core 4)
1
1676
by: Muddasir | last post by:
Hello everyone. I am facing problem in downloading .xls file. I generate report and save data in excel sheet on server. and once user click the 'save data in excel format', an excel sheet is been created on the server.once created then user can download that file. i am able to download file but the problem is that when user apply sorting to data and then save data in excel sheet. the file on the server contains the data in the same...
4
2736
by: Xavier | last post by:
Hi, I try to access to a Bluetooth GPS data-logger with Python. I use pySerial. Sending and receiving little messages (~100 char) works fine. However, when I ask the GPS to dump the trails, it returns some Mbytes and here is the problem : in the stream of bytes, I randomly losts chunks of ~100bytes.
0
8249
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.