note 32674 rejected from features.file-upload by didou

From: Date: Wed, 04 Jun 2003 09:09:16 +0000
Subject: note 32674 rejected from features.file-upload by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-49697@lists.php.net to get a copy of this message
Note Submitter: pnieuwdorp@yahoo.com ---- I got a problem with uploading files larger then 1MB via http post and save it in MySQL. I read that you can split files and save each part and then combine the parts. here's my code; can anyone tell me why it doesn't work? it gives an empty blob when i post a file larger then 1mb. when i post a file smaller then it works fine. TABLE: CREATE TABLE test ( id INT not null AUTO_INCREMENT, name VARCHAR (64) not null, type VARCHAR (64) not null, length INT not null, content MEDIUMBLOB not null, PRIMARY KEY (id) ) CODE: define("MAX_SQL",906240); $fp = fopen($HTTP_POST_FILES[file][tmp_name],"rb"); $sql = "INSERT INTO test (name,type,length) VALUES ('" . $HTTP_POST_FILES[file][name] . "','" . $HTTP_POST_FILES[file][type] . "','" . filesize($HTTP_POST_FILES[file][tmp_name]) . "')"; mysql_query($sql) or die("Bad luck1"); $id = mysql_insert_id(); $counter = 0; while (!feof($fp)){ $counter = $counter + 1; $data = addslashes(fread($fp,MAX_SQL)); // check if this is the first time you insert the blob so don't use concat if ($counter == 1) { $sql = "UPDATE test SET content = '$data' WHERE id = '$id'"; } else { $sql = "UPDATE test SET content = CONCAT(content,'$data') WHERE id = '$id'"; } mysql_query($sql) or die("Update with blob fails"); }

« previous php.notes (#49697) next »