ID: 43306 Comment by: arasan at mahiti dot org Reported By: d dot tas40 at chello dot nl Status: No Feedback Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.2.5 New Comment:
I've used this code but the download rate is very slow compared to ordinary download. whether there is any way to overcome this? Previous Comments: ------------------------------------------------------------------------ [2008-09-25 04:51:26] [EMAIL PROTECTED] Please try without any Content-Length header, your HTTP server is probably using a chunked transfert encoding. Also try with a Content-Type like 'application/octet-stream'. Also check the character_set_* variables in your MySQL connection, the server may try to convert the query or the results if some variables do not match (blobs are binary but queries and results are not). ------------------------------------------------------------------------ [2008-09-25 02:54:18] alphajet1024 at hotmail dot com I have the very same problem, but my host server is PHP Version 4.3.11 with Linux OS, i use the following code snippest to recieve the file from form and upload it to a BLOB field in SQL, the code works fine with all file extensions, except rar and zip files, they mostly are corrupted. upload.php <?php if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include('conf.php'); // open database connection $connection = mysql_connect($host, $user, $pass) or die ('Unable to connect!'); // select database mysql_select_db($db) or die ('Unable to select database!'); $query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed ' . mysql_error()); ?> //////////////////////////////////////////////////////////////////// download.php <?php if(isset($_GET['id'])) { // if id is set then get the file with the id from database include('conf.php'); // open database connection $connection = mysql_connect($host, $user, $pass) or die ('Unable to connect!'); // select database mysql_select_db($db) or die ('Unable to select database!'); $id = $_GET['id']; $query = "SELECT name, type, size, content " . "FROM upload WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($name, $type, $size, $content) = mysql_fetch_array($result); header("Content-length: $size"); header("Content-type: $type"); header("Content-Disposition: attachment; filename=$name"); } php echo $content; ?> ------------------------------------------------------------------------ [2008-01-12 17:08:06] webmaster at anpera dot net I have a similar problem with PHP 5.2.4 / 5.2.5 with Apache2.2 under Windows 2003. Downloaded files are missing exactly 15 bytes at the end. ZIP and RAR files can't be opened correctly after download but definitely are okay on the server's hard drive. With $filesize=filesize($filename)+15; the downloads are working. $size = @filesize($filename)+15; header('Pragma: public'); [...] header("Content-Length: $size"); $fp = @fopen($filename, 'rb'); [...] while (!feof($fp)){ echo fread($fp, 8192); } fclose($fp); [...] flush(); ------------------------------------------------------------------------ [2007-11-23 01:00:00] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2007-11-15 22:46:55] [EMAIL PROTECTED] Are you sure there aren't any errors happening there? Check the file you downloaded using e.g. notepad.. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/43306 -- Edit this bug report at http://bugs.php.net/?id=43306&edit=1