ghostwin8网站奖别人做/长春头条新闻今天
我有一个代码块,只要扩展名为小写jpg,就可以上传图像并创建缩略图,但如果图像是大写的JPG,则不会上传图像.当我重命名图像时,例如example.JPG到example.jpg,它会上传.但是example.JPG不会上传,我没有错误.这对我没有任何意义.有没有人对此有解释?这是我的代码:
function createThumbnail($filename) {
require 'config.php';
if(preg_match('/[.](jpg)$/', $filename)) {
$im = imagecreatefromjpeg($filename.$path_to_image_directory);
} else if (preg_match('/[.](gif)$/', $filename)) {
$im = imagecreatefromgif($path_to_image_directory . $filename);
} else if (preg_match('/[.](png)$/', $filename)) {
$im = imagecreatefrompng($path_to_image_directory . $filename);
}
$ox = imagesx($im);
$oy = imagesy($im);
$nx = $final_width_of_image;
$ny = $final_height_of_image;
$nm = imagecreatetruecolor($nx, $ny);
imagecopyresampled($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy);
if(!file_exists($path_to_thumbs_directory)) {
if(!mkdir($path_to_thumbs_directory)) {
die("There was a problem. Please try again!");
}
}
imagejpeg($nm, $path_to_thumbs_directory . $filename);
$tn = '';
$tn .= '
Congratulations. Your file has been successfully uploaded, and a thumbnail has been created.';
echo $tn;
}
?>
配置文件:
$final_width_of_image = 300;
$final_height_of_image = 300;
$path_to_image_directory = '';
$path_to_thumbs_directory = '-tn';
?>