Php 多个映像上载导致500个内部服务器错误
我想在我的网站上实现多个部分,访问者可以上传他们的图片来显示。 我让它在服务器上的一个测试文件夹中完美地工作,在那里它回显“文件是一个图像。[文件]成功上传”,图像显示在服务器上 然而,随着该脚本在网站中的实际实现(我将脚本复制到另一个文件夹),我得到了返回:500内部服务器错误 你们中有人知道是什么导致了这个问题吗 HTML表单(在/entries.php中):Php 多个映像上载导致500个内部服务器错误,php,image,upload,Php,Image,Upload,我想在我的网站上实现多个部分,访问者可以上传他们的图片来显示。 我让它在服务器上的一个测试文件夹中完美地工作,在那里它回显“文件是一个图像。[文件]成功上传”,图像显示在服务器上 然而,随着该脚本在网站中的实际实现(我将脚本复制到另一个文件夹),我得到了返回:500内部服务器错误 你们中有人知道是什么导致了这个问题吗 HTML表单(在/entries.php中): 无标题文件 在此处上载您的条目!: PHP脚本(在upload.PHP中): 可能需要增加php.ini中的上传最大文件大
无标题文件
在此处上载您的条目!:
PHP脚本(在upload.PHP中):
可能需要增加php.ini中的上传最大文件大小。
此命令将为您提供值,然后您可以进入php.ini并在不够时增加它。
对于FcgidMaxRequestLen
,可能需要增加。
在这种情况下,您可以在httpd.conf中创建一个新的apache指令,如下所示
FcgidMaxRequestLen字节
MaxRequestLen 15728640
您的托管公司不允许PHP访问您为上载指定的目录。
由于每个托管公司都有不同的配置,因此流程可能会有所不同。但这是戈达迪和普莱斯克的过程
如果该目录中有.htaccess,请暂时移动它,然后重试。
您需要将其从PHP脚本所在的目录和文件上载的目录中移动。如果这允许上传,显然您知道.htaccess中有一条规则/指令导致了问题。检查您的Web服务器(可能是apache2)日志文件,它会告诉您500个内部错误是什么,感谢您的回复。遗憾的是,我的Web服务器由GoDaddy托管。我可以看到谁正在连接哪个页面的日志文件,但没有错误日志。谢谢您的回复。我已经确保没有超过文件大小限制,而且fileUpload=on与您的编辑有关:我不知道如何访问httpd.conf配置。我的托管公司使用“Plesk”来配置服务器,但它似乎非常有限。而且,我在任何地方都看不到.htaccess。我还检查了权限,这应该不是问题,看看这个
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../../style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#000000">
<form action="upload.php" method="post" enctype="multipart/form-data"><p class="text">
Upload your entry here!:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit"></p>
</form>
</body>
</html>
<?php
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
echo ini_get ("upload_max_filesize");
<IfModule mod_fcgid.c>
MaxRequestLen 15728640
</IfModule>