0
나는 내 사이트에 이미지를 업로드하려면 다음 PHP 스크립트가 :이미지로 인해 액세스 할 수 없습니다 : 오류 메시지 '401 권한이 잘못된 자격 증명 때문에 액세스가 거부'
function saveImage2Server($input_name)
{
$originalFileName = basename($_FILES[$input_name]["name"]);
$fileType = exif_imagetype($_FILES[$input_name]["tmp_name"]);
$fileSize = $_FILES[$input_name]["size"];
$allowedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_PNG);
$maxSize = 819200;
// first check if the file is of allowed type
if(in_array($fileType, $allowedTypes))
{
//check if the size is under 800kb
if($fileSize<=$maxSize)
{
$dotIndex = strrpos($originalFileName, ".");
$extension = strtolower(substr($originalFileName, $dotIndex));
$newFileName = uniqid().uniqid().$extension;
move_uploaded_file($_FILES[$input_name]["tmp_name"], "../../images/".$newFileName);
return $newFileName;
}
else // if it's above 800kb
{
echo("The file size exceeds 800kb");
header("Location: ../");
die(error);
}
}
else // if the type isn't allowed
{
echo("This file type isn't allowed");
header("Location: ../");
die(error);
}
}
을 스크립트는 내 로컬 서버 (WAMP)에서 정상적으로 작동하며 파일을 업로드 한 후에 정상적으로 액세스 할 수 있습니다. 그러나 IIS에서 파일을 업로드 할 때 액세스하려고 할 때 다음과 같은 401 오류 메시지가 표시됩니다. 401 - Unauthorized: Access is denied due to invalid credentials.
문제를 해결하기 위해 내가 뭘하거나 내 호스팅 회사에서해야합니까?
분명히 권한 부여 상속에 문제가있었습니다. 그들은 또한 보안상의 이유로 ini_set을 차단 했으므로 직접 처리 할 수 없었습니다. 이제 모든 것이 잘됩니다. 당신의 답변에 감사드립니다! – Igal