[SOLVED] Uploading file to Longblob is corrupt?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

And the --> thing?
rustynail wrote:Is it possible that the version of MySQL that I am using has a bug
mysql delivers correct data, as was shown by
download:
row[filesize]: 674
strlen(bin_data): 900
strlen(datafix): 674
ord: 50 4b 03 04 14 00 00 00 08 00
50 -> P, not 20->space, so that's alright.


What about dbinfo.inc.php? Is there a space before <?php oder after ?> ..somewhere?

And another test for download.php

Code: Select all

$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");
flush();
headers_sent($h_file, $h_line);
echo $h_file, ':', $h_line;
// echo $datafix;
rustynail
Forum Newbie
Posts: 21
Joined: Wed Jul 05, 2006 12:14 pm

Post by rustynail »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[quote="volka"]


What about dbinfo.inc.php? Is there a space before <?php oder after ?> ..somewhere?

[/quote]

Cut and paste of dbinfo.inc.php

Code: Select all

<?
$username="xxx";
$password="xxxxxxx";
$database="voc_doc";
$host="localhost";
?>
Will check the download script out shortly. Thanks!


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Hm, ich can highlight a character after ?>. Might be the board but it might also be present in the file and therefore be output.
rustynail
Forum Newbie
Posts: 21
Joined: Wed Jul 05, 2006 12:14 pm

Post by rustynail »

volka wrote:
And another test for download.php

Code: Select all

$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");
flush();
headers_sent($h_file, $h_line);
echo $h_file, ':', $h_line;
// echo $datafix;
This returned :0
rustynail
Forum Newbie
Posts: 21
Joined: Wed Jul 05, 2006 12:14 pm

Post by rustynail »

volka wrote:Hm, ich can highlight a character after ?>. Might be the board but it might also be present in the file and therefore be output.
When brought up in an editor, there was a space after the ?>. Whoops, let me check.
rustynail
Forum Newbie
Posts: 21
Joined: Wed Jul 05, 2006 12:14 pm

Post by rustynail »

rustynail wrote:
volka wrote:

What about dbinfo.inc.php? Is there a space before <?php oder after ?> ..somewhere?
Cut and paste of dbinfo.inc.php

Code: Select all

<?
$username="xxx";
$password="xxxxxxx";
$database="voc_doc";
$host="localhost";
?>
Will check the download script out shortly. Thanks!

Ok now there was a space after the ?> in dbinfo.inc.php and after it was removed things are working as they should :D (I owe you one big time). Thank you Thank you Thank you!!!!

Please explain to me on why this made such a dramatic difference in how the file was downloaded? Was it because it would have been an html <space> that was transferred before the echo of the binary data?

By my default thinking, that should have been ignored. Something so little caused me so many headaches you wouldn't believe.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Anything outside a <?php ?> block is sent as-is to the client.That also applies to included files. If the script execution reaches the non-php block, all characters are sent to the client.
Obviously you have some kind of buffer active or otherwise the header() statements would have failed. And I just learned, that flush() is not enough to clear a buffer installed by output_buffering=4096 in php.ini :-S
It should have been

Code: Select all

ob_flush();
flush();
headers_sent($h_file, $h_line);
echo $h_file, ':', $h_line;
Post Reply