【发布时间】:2011-03-13 17:44:19
【问题描述】:
我最近将一个为 LAMP 环境编写的网站迁移到了 Windows Server 2008。我现在已经设法让几乎所有东西都能正常工作,但最后一个问题似乎无法解决。
我让管理员用户上传一张照片,该照片将通过 PHP 脚本调整为大文件和小文件。两个文件都已完美上传,但大文件无法显示,查看时会导致“500 内部服务器错误”?
我可以登录服务器打开小文件和大文件,但网站上只显示小文件?我已经复制了下面的 PHP 脚本,但两个文件的权限似乎是相同的。
我正在使用 PHP、IIS7 和 Windows Server 2008。希望有人能提供帮助,
史蒂文。
// only process if the first image has been found
if(isset($image_file)) {
// get photo attributes
$image_filename = $image_file['name'];
$image_temp = $image_file['tmp_name'];
$image_ext = substr($image_filename,strpos($image_filename,'.'),strlen($image_filename)-1);
// validate photo attributes
if(strtolower($image_ext) == '.jpg' && filesize($image_temp) <= 4194304) {
// create custom timestamp
$image_timestamp = date('dmYHis');
// clean up filename
$image_filename = trim(str_replace('\'','',$image_filename));
$image_filename = str_replace('\\','',$image_filename);
$image_filename = str_replace('&','',$image_filename);
$image_filename = str_replace(' ','-',$image_filename);
// set file names
$image_large_file = strtolower($image_timestamp . '-large-1-' . $image_filename);
$image_small_file = strtolower($image_timestamp . '-thumb-1-' . $image_filename);
// image url source
$image_source = $_SERVER['DOCUMENT_ROOT'] . '/images/';
// upload image file
if(move_uploaded_file($image_temp,$image_source . $image_large_file)) {
// resize, save & destroy LARGE image
list($image_width,$image_height) = getimagesize($image_source . $image_large_file);
$image_container = imagecreatetruecolor(420,315);
$image_temp = imagecreatefromjpeg($image_source . $image_large_file);
imagecopyresampled($image_container,$image_temp,0,0,0,0,420,315,$image_width,$image_height);
imagejpeg($image_container,$image_source . $image_large_file,75);
imagedestroy($image_container);
// resize, save & destroy SMALL image
list($image_width,$image_height) = getimagesize($image_source . $image_large_file);
$image_container = imagecreatetruecolor(90,68);
$image_temp = imagecreatefromjpeg($image_source . $image_large_file);
imagecopyresampled($image_container,$image_temp,0,0,0,0,90,68,$image_width,$image_height);
imagejpeg($image_container,$image_source . $image_small_file,100);
imagedestroy($image_container);
}
else
$status = '<h3 class="red">Sorry, but there was a problem uploading one of the images to the server</h3>';
}
else
$status = '<h3 class="red">Please check that all the image size\'s are less than 4MB and they\'re all in JPG format</h3>';
}
【问题讨论】:
-
IIS 有错误日志,不是吗? 500 错误代码几乎可以保证您的答案会出现在该错误日志中。
-
可能错误类似于 Call to undefined function imagecreatetruecolor()
标签: php iis-7 windows-server-2008