Php 将网站移动到新服务器后,上载图像不起作用

Php 将网站移动到新服务器后,上载图像不起作用,php,http,iis,upload,permissions,Php,Http,Iis,Upload,Permissions,我正在尝试使用下面的脚本上传图像 我们的旧服务器没有任何问题。当我将网站迁移到windows 2012、iis 8、PHP5.2(相同版本)时,我们就无法让它正常工作 不幸的是,我们花了数小时试图启用php日志记录,但没有成功 我怀疑问题在于权限 问题 要使用下面的脚本,需要哪些权限?我立即为一个可怕的问题道歉,但我对php的了解很少,我需要关于如何着手解决这个问题的指导 <?php include '../Check.php'; function cropImage($nw, $nh

我正在尝试使用下面的脚本上传图像

我们的旧服务器没有任何问题。当我将网站迁移到windows 2012、iis 8、PHP5.2(相同版本)时,我们就无法让它正常工作

不幸的是,我们花了数小时试图启用php日志记录,但没有成功

我怀疑问题在于权限

问题 要使用下面的脚本,需要哪些权限?我立即为一个可怕的问题道歉,但我对php的了解很少,我需要关于如何着手解决这个问题的指导

<?php

include '../Check.php';

function cropImage($nw, $nh, $source, $stype, $dest) {

    $size = getimagesize($source);
    $w = $size[0];
    $h = $size[1];

    switch($stype) {
        case 'gif':
        $simg = imagecreatefromgif($source);
        break;
        case 'jpg':
        $simg = imagecreatefromjpeg($source);
        break;
        case 'png':
        $simg = imagecreatefrompng($source);
        break;
    }

    $dimg = imagecreatetruecolor($nw, $nh);

    $wm = $w/$nw;
    $hm = $h/$nh;

    $h_height = $nh/2;
    $w_height = $nw/2;

    if($w> $h) {

        $adjusted_width = $w / $hm;
        $half_width = $adjusted_width / 2;
        $int_width = $half_width - $w_height;

        imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);

    } elseif(($w <$h) || ($w == $h)) {

        $adjusted_height = $h / $wm;
        $half_height = $adjusted_height / 2;
        $int_height = $half_height - $h_height;

        imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);

    } else {
        imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
    }

    imagejpeg($dimg,$dest,100);
} 



// JQuery File Upload Plugin v1.4.1 by RonnieSan - (C)2009 Ronnie Garcia
if (!empty($_FILES)) {
//  $filename = $_FILES['Filedata']['tmp_name'];
//  $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['path'] . '/';
//  $filename2 =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
//  
//  // Uncomment the following line if you want to make the directory if it doesn't exist
//  // mkdir(str_replace('//','/',$targetPath), 0755, true);
//  
//  move_uploaded_file($filename,$filename2);




              $imagename = $_FILES['Filedata']['name'];
              $source = $_FILES['Filedata']['tmp_name'];
              $target = "../Account/uploadimages/".$imagename;
              move_uploaded_file($source, $target);

              $imagepath = $imagename;

              //Save Original

              $save = "../Account/uploadimages/" . $USR_ID . ".jpg" ; //This is the new file you saving
              $file = "../Account/uploadimages/" . $imagepath; //This is the original file

              list($width, $height) = getimagesize($file) ; 

              $modwidth = 500; 
              $modheight = 500; 

              $diff = $width / $modwidth;

              $modheight = $height / $diff; 
              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 

                //Save Small Version    

              $save = "../Account/profile_small/" . $USR_ID . ".jpg" ; //This is the new file you saving
              $file = "../Account/uploadimages/" . $USR_ID . ".jpg" ; //This is the original file

              list($width, $height) = getimagesize($file) ; 

              $modwidth = 225; 

              $diff = $width / $modwidth;

              $modheight = $height / $diff; 
              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 



                //Save Square Version   

              $save = "../Account/profile_square/" . $USR_ID . ".jpg"; //This is the new file you saving
              $file = "../Account/uploadimages/" . $USR_ID . ".jpg" ; //This is the original file

                cropImage(60, 60, $file, 'jpg', $save);

            include '../khhCustomConnect.php';
 //Set their USR_HasImage to 1 on their associate profile so that it checks before trying to display profile photo.
            $update_hasimage = mssql_query("UPDATE Associate SET USR_HasImage = '1' WHERE USR_ID = '$USR_ID'") or die ("Error - No option deleted"); 


//Send email to helpdesk
    //Get User that submitted email address for from address
    $emaillookup = mssql_query("Select * FROM Associate Where USR_ID = '$USR_ID'");
    $USR_Email = mssql_result($emaillookup,0,'USR_Email');
    $USR_First = mssql_result($emaillookup,0,'USR_First');
    $USR_Last = mssql_result($emaillookup,0,'USR_Last');


//Start Menu Permission Detail - Change Variable and Title.


// Email will go to their Email. 
$to  = 'helpdesk@khhsl.com'; // note the comma

// subject
$subject = $USR_First . ' ' . $USR_Last . ' - New Picture Uploaded';

// message
$message = '
' . $USR_First . ' ' . $USR_Last . ' has changed their photo on khhConnect. Please upload to AD. Here is link to image: http://xx/xx/Account/profile_small/' . $USR_ID . '.jpg 

<br /><a href="http://xx/xx/Account/profile_small/' . $USR_ID . '.jpg">http://xx/xx/Account/profile_small/' . $USR_ID . '.jpg</a><br><br>


<img src="http://xx/xx/Account/profile_small/' . $USR_ID . '.jpg"><img />


';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: ' . $USR_First . ' ' . $USR_Last . ' <' . $USR_Email . '>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers) or exit("could not send");



}

echo '1'; // Important so upload will work on OSX
?>

您可能需要检查是否在临时文件夹中找到上载的文件,可能需要添加IUSR\u MACHINENAME或IUSR\u MYMACHINENAME帐户写入权限,并指定在未上载文件时尝试写入的文件夹。

上载时有错误吗?可能要检查服务器logs@Eldar找不到服务器logs@Eldar发生的唯一一件事是页面得到刷新。我认为在IIS上运行php可能是问题所在你是说“IUSR_MACHINENAME”还是“IUSR_MYMACHINENAME”?你是对的!!!需要添加的只是本地计算机上的IUSR