上传的照片结果在";500内部服务器错误";-PHP/IIS7/Windows Server 2008
我最近将一个为LAMP环境编写的网站移至Windows Server 2008。我现在已经设法让所有的东西都运转起来了,但我还有最后一个问题,我似乎无法解决 我让管理员用户上传一张照片,通过PHP脚本将照片大小调整为大文件和小文件。两个文件都得到了完美的上传,但是大文件不会显示,并且在查看时会导致“500内部服务器错误” 我可以登录到服务器并打开大小文件,但只有小文件显示在网站上?我复制了下面的PHP脚本,但两个文件的权限似乎相同 我正在使用PHP、IIS7和Windows Server 2008。希望有人能帮忙 史蒂文上传的照片结果在";500内部服务器错误";-PHP/IIS7/Windows Server 2008,php,iis-7,windows-server-2008,Php,Iis 7,Windows Server 2008,我最近将一个为LAMP环境编写的网站移至Windows Server 2008。我现在已经设法让所有的东西都运转起来了,但我还有最后一个问题,我似乎无法解决 我让管理员用户上传一张照片,通过PHP脚本将照片大小调整为大文件和小文件。两个文件都得到了完美的上传,但是大文件不会显示,并且在查看时会导致“500内部服务器错误” 我可以登录到服务器并打开大小文件,但只有小文件显示在网站上?我复制了下面的PHP脚本,但两个文件的权限似乎相同 我正在使用PHP、IIS7和Windows Server 200
// 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>';
}
//仅在找到第一个映像时处理
如果(isset($image_文件)){
//获取照片属性
$image_filename=$image_文件['name'];
$image_temp=$image_文件['tmp_name'];
$image\u ext=substr($image\u filename,strpos($image\u filename,“.”),strlen($image\u filename)-1;
//验证照片属性
如果(strtolower($image\u ext)='.jpg'&&filesize($image\u temp)我知道这个问题是4年前问的,但我刚刚遇到了同样的问题,我想我会给以后可能来这里的任何人留下一个答案
,但基本前提是修改PHP最初上载到的临时文件夹的权限。允许IUSR帐户对临时文件夹进行读取访问将允许他们在文件到达其最终目标时查看该文件。假定IIS7将从临时文件夹向临时上载文件授予权限,当临时上载文件移动到您的网站目录将保留这些临时文件夹权限
在安全方面,您允许对临时文件夹进行读取访问;因此,如果您的敏感信息在任何时候都会出现在临时文件夹中,您可能需要找到另一种解决方案
可以找到更多的信息我也遇到了同样的问题,我想这会对某些人有所帮助
右键单击上载目录/文件夹并选择“属性”
转到“安全”选项卡
单击编辑
在组或用户名下选择“IUSR”
在IUSR权限下选择“读取并执行”
单击“应用”和“确定”
在IIS上发现此错误有一个错误日志,不是吗?一个500错误代码几乎可以保证您的答案将出现在该错误日志中。该错误可能类似于调用未定义的函数ImageCreateTureColor()