我有一个处理文件上传的脚本。我上传的文件小于1 MB,但当文件超过1 MB时,脚本似乎将临时文件路径设置为null。以下是以下脚本:
$total = count($_FILES['DocName']['tmp_name']);
for($i = 0; $i < $total; $i++) {
// Get the temp file path
$tmpFilePath = $_FILES['DocName']['tmp_name'][$i];
// Check if we have a path
if ($tmpFilePath != "") {
// Variables from form
$FolderName = $_POST['FolderName'];
$FolderName = stripslashes($FolderName);
$FolderName = mysql_real_escape_string($FolderName);
//Setup our new file path
// Check if folder name is home, if so, set the file path to that folder
if ($FolderName == "Home") {
$target_dir = "../../cdn.brmbc.com/usercontent/".$UserID."/";
}
// If the folder name is not home, make the file go to that folder
else {
$IsInFolder = 1;
$target_dir = "../../cdn.brmbc.com/usercontent/".$UserID."/".$FolderName."/";
}
$target_file = $target_dir . basename($_FILES["DocName"]["name"][$i]);
$FileType = pathinfo($target_file,PATHINFO_EXTENSION);
$DocumentName = $_FILES["DocName"]["name"][$i];
echo $tmpFilePath . "<br>";
echo $target_file . "<br>";
echo $FileType . "<br>";
echo $DocumentName . "<br>";
}
// Go home if there is no temp path
else {
echo $tmpFilePath . "<br>" . "Failed to upload";
}
}
是否有任何关于代码的错误,或者这仅仅是服务器问题?
答案 0 :(得分:1)
如果您的上传工作适用于1MB以下的文件,我猜它是一个php.ini设置。
如果您可以访问php.ini搜索名为“max_file_uploads”的设置 - 我敢打赌它设置为1MB。
答案 1 :(得分:0)
我认为你必须改变php.ini文件。在php.ini文件中,您将找到
upload_max_filesize=2M
像这样的事情。你必须增加文件大小。我认为你的就像是
upload_max_filesize=1M
增加文件大小后应该是okey。