Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
内部服务器错误500上载图像iOS php_Php_Objective C_Image_Post - Fatal编程技术网

内部服务器错误500上载图像iOS php

内部服务器错误500上载图像iOS php,php,objective-c,image,post,Php,Objective C,Image,Post,我读过很多有同样问题的人,他们都很相似,都与我的服务器设置有关,确保images dir拥有755权限,出于某种原因,我看到我的users子文件夹设置为777,我创建了php.ini文件,我确保upload\u max\u filesize设置正确,我的php.ini设置正确。我从许多不同的教程中尝试了几种不同的编码技术,都输出了相同的错误 这是我的NSlog中的错误 myproject[11784:907] test <!DOCTYPE HTML PUBLIC "-//IETF//DTD

我读过很多有同样问题的人,他们都很相似,都与我的服务器设置有关,确保images dir拥有755权限,出于某种原因,我看到我的users子文件夹设置为777,我创建了php.ini文件,我确保upload\u max\u filesize设置正确,我的php.ini设置正确。我从许多不同的教程中尝试了几种不同的编码技术,都输出了相同的错误

这是我的NSlog中的错误

myproject[11784:907] test <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 webmaster@myproject.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
还有我的PHP

<?php
// removed connection 
$mysqli = new mysqli($host, $username, $password, $database);
if ($stmt = $mysqli->prepare("INSERT INTO `user` SET imagepath=? WHERE email=?")) 
{
    $stmt->bind_param('ss', $albumname, $email);

$uploaddir = 'images/users/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

}
$albumname = $uploadfile;
    $email = $_POST['email'];
    $stmt->execute();
    $stmt->close(); 
    }


else {
    printf("Prepared Statement Error: %s\n", $mysqli->error);
}

$mysqli->close();
?>

错误500是服务器端的错误


我建议您尝试从服务器上传到服务器本身,这样您可能会得到更多信息,知道哪里出了问题。另外,请检查web服务器、nginx、appache或您运行过的任何程序的错误日志,您将在那里找到导致错误的原因。

虽然我无法从您的代码中看出500错误是什么,但我强烈建议您确保您的PHP ini文件已启用错误日志,并查看日志文件。在大多数情况下,500错误是由PHP引擎中的运行时错误引起的,它将输出到日志文件,或者如果启用了display_errors,将直接输出到浏览器


10次中有9次,只要你能读取日志文件,错误就很容易修复。

我想我应该提到,我已经启用了错误日志记录,并且我得到的
文件不存在:/home/myproject/public\u html/500.shtml
我得到的文件不存在错误,请阅读上面的注释,但所有我都摆脱了这个错误,我没有创建一个物理页面来显示错误,我不明白这有什么关系。我也可以通过一个简单的html表单上传到我的服务器上……这个错误只是说你没有自定义文件来显示服务器的500个错误,但这不是错误的来源或原因。我可以这么说,没什么奇怪的。
<?php
// removed connection 
$mysqli = new mysqli($host, $username, $password, $database);
if ($stmt = $mysqli->prepare("INSERT INTO `user` SET imagepath=? WHERE email=?")) 
{
    $stmt->bind_param('ss', $albumname, $email);

$uploaddir = 'images/users/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

}
$albumname = $uploadfile;
    $email = $_POST['email'];
    $stmt->execute();
    $stmt->close(); 
    }


else {
    printf("Prepared Statement Error: %s\n", $mysqli->error);
}

$mysqli->close();
?>