note 23495 deleted from features.file-upload by aidan
| From: | aidan@php.net | Date: | Tue, 12 Oct 2004 08:42:24 +0000 |
| Subject: | note 23495 deleted from features.file-upload by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78397@lists.php.net to get a copy of this message | ||
Note Submitter: rynop2000 at hotmail dot com
----
--HANDLING LARGE FILE UPLOADS and entering into a MySQL blob field--
Hope this helps someone as it was hard to fig out. MySQL default buffer and packets are set small.
here is a method to get aroudn it.
$filehandle = fopen($addfile, "r");
$filesize = filesize($addfile);
//now this is bullshit, but have to read the file piece by piece and insert because the mysql server
is set up to only handle 1meg inserts (small buffer and packet).
$buffer = addslashes(fread($filehandle, 906240));
$query = "Insert into files (file, filename, size, userid ) values
('$filedata','$addfile_name', '$filesize')";
$this->query($query);
$id = mysql_insert_id($this->link_id());
while (!feof ($filehandle)) {
$buffer = addslashes(fread($filehandle, 906240));
$query = "UPDATE files SET file = concat('$buffer') where id='$id'";
$this->query($query);
}
fclose ($filehandle);