note 23495 modified in features.file-upload by didou
| From: | didou@php.net | Date: | Fri, 03 Oct 2003 10:34:08 +0000 |
| Subject: | note 23495 modified in features.file-upload by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57686@lists.php.net to get a copy of this message | ||
--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);
--was--
--HANDLING LARGE FILE UPLOADS and entering into a MySQL blob field--
Hope this helps someone as it was a bitch 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);
http://www.php.net/manual/en/features.file-upload.php