note 23495 added to features.file-upload

From: Date: Fri, 19 Jul 2002 14:57:18 +0000
Subject: note 23495 added to features.file-upload
Groups: php.notes 
Request: Send a blank email to php-notes+get-33310@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 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 http://master.php.net/manage/user-notes.php?action=edit+23495 http://master.php.net/manage/user-notes.php?action=delete+23495 http://master.php.net/manage/user-notes.php?action=reject+23495

« previous php.notes (#33310) next »