Hi All,
I have an upload script that's been working fine till about two weeks ago, I've asked the server support people if they've changed anything, but I'm not having much luck getting a straight answer.
I have a feeling they've recently upgraded php or something and was just wondering if anyone can see any problem with my code that could be affected by this?
//Image Variables
$BigImagePath = '../../BandImages/';
$BigImageWidth = '1000';
$BigImageHeight = '2000';
$MaxFileSize = 100000000;
$Extensions = array('.jpg','.jpeg');
if (is_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'])) {
if ($HTTP_POST_FILES['filename']['size'] > $MaxFileSize) {
$error .= "<li>The filesize is too big, please make it smaller and try again</li><br />";
}
//Get extension of file
$ImageExt = strtolower(substr($filename,strrpos($filename,".")));
//Check IF file has allowed extension
if (in_array($ImageExt, $Extensions)) {
//If there are no errors
if (empty($error)) {
//If File is a Jpeg Resize Image Using GD
if ( $ImageExt == '.jpg' || $ImageExt == '.jpeg' ) {
$Bimage = $HTTP_POST_FILES['filename']['tmp_name'];
$Bmax_width = $BigImageWidth;
$Bmax_height = $BigImageHeight;
$Bsize = GetImageSize($Bimage);
$Bwidth = $Bsize[0];
$Bheight = $Bsize[1];
$Bx_ratio = $Bmax_width / $Bwidth;
$By_ratio = $Bmax_height / $Bheight;
if ( ($Bwidth <= $Bmax_width) && ($Bheight <= $Bmax_height) ) {
$Btn_width = $Bwidth;
$Btn_height = $Bheight;
}
else if (($Bx_ratio * $Bheight) < $Bmax_height) {
$Btn_height = ceil($Bx_ratio * $Bheight);
$Btn_width = $Bmax_width;
}
else {
$Btn_width = ceil($By_ratio * $Bwidth);
$Btn_height = $Bmax_height;
}
$Bsrc = ImageCreateFromJpeg("$Bimage");
$Bdst = ImageCreateTrueColor($Btn_width,$Btn_height);
ImageCopyResampled($Bdst, $Bsrc, 0, 0, 0, 0,
$Btn_width,$Btn_height,$Bwidth,$Bheight);
ImageJpeg($Bdst, $Bimage, -1);
ImageDestroy($Bsrc);
ImageDestroy($Bdst);
}
//Delete file if it exists
if (!empty($HTTP_POST_FILES['filename']['name'])) {
if (file_exists('../../BandImages/'.$HTTP_POST_FILES['filename']['name'])) {
unlink('../../BandImages/'.$HTTP_POST_FILES['filename']['name'].'');
}
}
//Upload Image
$BUpload = copy($HTTP_POST_FILES['filename']['tmp_name'], $BigImagePath .$HTTP_POST_FILES['filename']['name']);
//If files didn't upload display message
if (!$BUpload) {
$error .= "<li>There was an error uploading this image, please try again</li><br />";
}
}
$filename = $HTTP_POST_FILES['filename']['name'];
}
else {
$error .= "<li>That file type is not allowed, only .jpeg and .jpg</li><br />";
}
}
Thanks for any help.