smickus
01-09-2008, 04:31 PM
Okay, so I wrote a function which is handled on an "upload" form. everything processes fine.
function doUpload() {
rsort($_FILES);
array_pop($_FILES);
$y = count($_FILES);
$x = 0;
$imageallow = array('image/jpeg', 'image/gif', 'image/pjpeg');
$filenames = array();
while($x<$y) {
$filename = $_FILES[$x]['name'];
$filetype = $_FILES[$x]['type'];
$filesize = $_FILES[$x]['size'];
$filetmp = $_FILES[$x]['tmp_name'];
if(!in_array($filetype, $imageallow)) $this->error("File named \"".$_FILES[$x]['name']."\" does not have an allowed file type.");
if($filesize>1024000) $this->error("File name \"".$_FILES[$x]['name']."\" has a larger file size than that allowed.");
if($filetype=="image/gif") $ext = ".gif"; else $ext = ".jpg";
$length = 0;
$random = date("Ymd-His-").$x;
$filename = $random.$ext;
array_push($filenames, $filename);
if (is_uploaded_file($filetmp)) {
$imageBLOB = addslashes(file_get_contents($_FILES[$x]['tmp_name']));
}
$imageDim = getimagesize($_FILES[$x]['tmp_name']);
$user = $this->user;
$ip = $this->ip();;
$date = date("d/m/Y");
$q = "INSERT INTO image (user, ip, date, image, imageDim, imageName, imageSize, imageType) VALUES ('$user', '$ip', '$date', '{$imageBLOB}', '$imageDim[3]', '$filename', '$filesize', '$filetype')";
$result = $this->runSQL($q);
$x++;
}
echo "success!";
}
And everything works fine except when the image is put into the blob in the database, only 64kb gets put in... Is this to do with some default limit set? How do I re-set this limit...?
And so the final article looks like this (http://www.smickus.co.uk/image/1743)
which is bad :(
function doUpload() {
rsort($_FILES);
array_pop($_FILES);
$y = count($_FILES);
$x = 0;
$imageallow = array('image/jpeg', 'image/gif', 'image/pjpeg');
$filenames = array();
while($x<$y) {
$filename = $_FILES[$x]['name'];
$filetype = $_FILES[$x]['type'];
$filesize = $_FILES[$x]['size'];
$filetmp = $_FILES[$x]['tmp_name'];
if(!in_array($filetype, $imageallow)) $this->error("File named \"".$_FILES[$x]['name']."\" does not have an allowed file type.");
if($filesize>1024000) $this->error("File name \"".$_FILES[$x]['name']."\" has a larger file size than that allowed.");
if($filetype=="image/gif") $ext = ".gif"; else $ext = ".jpg";
$length = 0;
$random = date("Ymd-His-").$x;
$filename = $random.$ext;
array_push($filenames, $filename);
if (is_uploaded_file($filetmp)) {
$imageBLOB = addslashes(file_get_contents($_FILES[$x]['tmp_name']));
}
$imageDim = getimagesize($_FILES[$x]['tmp_name']);
$user = $this->user;
$ip = $this->ip();;
$date = date("d/m/Y");
$q = "INSERT INTO image (user, ip, date, image, imageDim, imageName, imageSize, imageType) VALUES ('$user', '$ip', '$date', '{$imageBLOB}', '$imageDim[3]', '$filename', '$filesize', '$filetype')";
$result = $this->runSQL($q);
$x++;
}
echo "success!";
}
And everything works fine except when the image is put into the blob in the database, only 64kb gets put in... Is this to do with some default limit set? How do I re-set this limit...?
And so the final article looks like this (http://www.smickus.co.uk/image/1743)
which is bad :(