Here's the code I'm using to upload if it helps:

if ($action == "upload") {
  include "";

  if (isset($binFile) && $binFile != "none") {
    $data = addslashes(fread(fopen($binFile, "rb"), filesize($binFile)));
    $strDescription = addslashes(nl2br($txtDescription));
    $sql = "INSERT INTO tbl_Files ";
    $sql .= "(description, bin_data, filename, filesize, filetype) ";
    $sql .= "VALUES ('$strDescription', '$data', ";
    $sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
    $result = mysql_query($sql, $db);
    echo "The new file was successfully added to the database.<br><br>";
    echo "<a href='main.php'>Continue</a>";

} else {


-----Original Message-----
From: Bastien Koert [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 21, 2006 2:07 PM
Subject: RE: [PHP-DB] help with file downloads from MySQL

If you load the data into the field with addslashes, have you tried
stripslashes on the way out?


>From: "Mickey Martin" <[EMAIL PROTECTED]>
>Subject: [PHP-DB] help with file downloads from MySQL
>Date: Tue, 21 Mar 2006 12:55:56 -0600
>Every time I try to download a file from MySQL it cannot be opened. 
>Using HexEdit, I noticed that all of the files are getting 0a added to 
>the beginning of them (happens with all browsers).
>I can look at the files with MySQL Query Browser and they don't have 
>the 0a.
>Using php 4.3.11, Solaris 8, Apache 2.0.54, MySQL 4.1.11.
>Here's what I'm using:
>mysql_select_db($database_ctnwww, $ctnwww); $query_Attachment = 
>sprintf("SELECT bin_data, filetype, filename, filesize FROM IssueAttach 
>WHERE id_files=%s", $_GET['id_files']); $Attachment = 
>mysql_query($query_Attachment, $ctnwww) or die(mysql_error()); 
>$row_Attachment = mysql_fetch_array($Attachment);
>   $data = $row_Attachment['bin_data'];
>   $name = $row_Attachment['filename'];
>   $size = $row_Attachment['filesize'];
>   $type = $row_Attachment['filetype'];
>   header("Content-type: $type");
>   header("Content-length: $size");
>   header("Content-Disposition: attachment; filename=$name");
>   header("Content-Description: PHP Generated Data");
>   echo $data;
>Thanks in advance,
>PHP Database Mailing List ( To unsubscribe, visit: 

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to