gilly914
December 23rd, 2007, 10:31 AM
Hey There,
I created a form for the users to upload images to my site.
I added some functions that edit the files so that they resize them and then save them on to the server, so they won't take up too much space.
The thing is, I'm able to upload every file up to about 200kb.
Above this, and the page gets stuck - I get a browser error.
I checked all the server settings like 'max_input_time', 'post_max_filesize', etc. and everything is ok, and i was even able to upload a 900kb .bmp file, but i can't do the same with .jpg
I added my code to view...
Can anyone help me here...???
// check if the files were really uploaded //
if (isset($_FILES['UserPhoto1']['name']) && is_uploaded_file($UserPhoto1)) {
// UPLOAD & RESIZE THE IMAGES //
// get the image sizes //
list($iwidth, $iheight, $type, $attr) = getimagesize($UserPhoto1);
$fileName1 = time();
if ($type == 2) {
$src_img1 = @imagecreatefromjpeg($UserPhoto1);
$fileName1 .= ".jpg";
} elseif ($type == 3) {
$src_img1 = @imagecreatefrompng($UserPhoto1);
$fileName1 .= ".png";
} elseif ($type == 1) {
$src_img1 = @imagecreatefromgif($UserPhoto1);
$fileName1 .= ".gif";
}
// check if the file needs to be resized //
if ($iwidth > $MaxWidth || $iheight > $MaxHeight) {
$P = $iheight / $iwidth;
if ($iheight > $MaxHeight) {
$NewHeight = $MaxHeight;
$NewWidth = $NewHeight / $P;
}
if ($iwidth > $MaxWidth) {
$NewWidth = $MaxWidth;
$NewHeight = $NewWidth * $P;
}
} else {
$NewWidth = $iwidth;
$NewHeight = $iheight;
}
$TmpImg1 = imagecreatetruecolor($NewWidth, $NewHeight);
imagecopyresized($TmpImg1, $src_img1, 0, 0, 0, 0, $NewWidth, $NewHeight, $iwidth, $iheight);
$NewFileName1 = "../images/customers/".$fileName1;
if ($type == 2) {
@imagejpeg($TmpImg1, $NewFileName1);
} elseif ($type == 3) {
@imagepng($TmpImg1, $NewFileName1);
} elseif ($type == 1) {
@imagegif($TmpImg1, $NewFileName1);
}
$UserFile1 = $NewFileName1;
}
I created a form for the users to upload images to my site.
I added some functions that edit the files so that they resize them and then save them on to the server, so they won't take up too much space.
The thing is, I'm able to upload every file up to about 200kb.
Above this, and the page gets stuck - I get a browser error.
I checked all the server settings like 'max_input_time', 'post_max_filesize', etc. and everything is ok, and i was even able to upload a 900kb .bmp file, but i can't do the same with .jpg
I added my code to view...
Can anyone help me here...???
// check if the files were really uploaded //
if (isset($_FILES['UserPhoto1']['name']) && is_uploaded_file($UserPhoto1)) {
// UPLOAD & RESIZE THE IMAGES //
// get the image sizes //
list($iwidth, $iheight, $type, $attr) = getimagesize($UserPhoto1);
$fileName1 = time();
if ($type == 2) {
$src_img1 = @imagecreatefromjpeg($UserPhoto1);
$fileName1 .= ".jpg";
} elseif ($type == 3) {
$src_img1 = @imagecreatefrompng($UserPhoto1);
$fileName1 .= ".png";
} elseif ($type == 1) {
$src_img1 = @imagecreatefromgif($UserPhoto1);
$fileName1 .= ".gif";
}
// check if the file needs to be resized //
if ($iwidth > $MaxWidth || $iheight > $MaxHeight) {
$P = $iheight / $iwidth;
if ($iheight > $MaxHeight) {
$NewHeight = $MaxHeight;
$NewWidth = $NewHeight / $P;
}
if ($iwidth > $MaxWidth) {
$NewWidth = $MaxWidth;
$NewHeight = $NewWidth * $P;
}
} else {
$NewWidth = $iwidth;
$NewHeight = $iheight;
}
$TmpImg1 = imagecreatetruecolor($NewWidth, $NewHeight);
imagecopyresized($TmpImg1, $src_img1, 0, 0, 0, 0, $NewWidth, $NewHeight, $iwidth, $iheight);
$NewFileName1 = "../images/customers/".$fileName1;
if ($type == 2) {
@imagejpeg($TmpImg1, $NewFileName1);
} elseif ($type == 3) {
@imagepng($TmpImg1, $NewFileName1);
} elseif ($type == 1) {
@imagegif($TmpImg1, $NewFileName1);
}
$UserFile1 = $NewFileName1;
}