这些文件是相对较小的XML,远远低于最大上传限制,我已将php.ini中的max_file_upload值调整为30.所有文件都可以以任意组合上传,最多16个。更重要的是,表单实际上不会发布。" POST。"它将动作到下一页,但是如果表单已经提交,我会输入一些代码来显示文本,如果选择了超过16个文件,它将赢得它。我对这一点感到茫然,对网络也没什么帮助。
<form method="post" enctype="multipart/form-data" name="uploadForm" id="uploadForm" action="?pa=uxf">
<table border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td valign="top"><label for="fileField"><strong>Upload XML Files to Repository:</strong></label><br /><?php
if(isset($_POST['upload'])) {
$fileCount = count($_FILES['fileToUpload']['tmp_name']);
echo '<br /><br />File Count: '.$fileCount.'<br />';
for ($i = 0; $i < $fileCount; $i++) {
echo '<br />';
$target_dir = 'uploads/';
$target_file = $target_dir.basename($_FILES['fileToUpload']['name'][$i]);
$uploadOk = 1;
$fileType = pathinfo($target_file,PATHINFO_EXTENSION);
$check = filesize($_FILES['fileToUpload']['tmp_name'][$i]);
if($check !== false) {
echo '<span style="color: #00AA00">File is an xml.</span><br />'.$check['mime'];
$uploadOk = 1;
} else {
echo '<span style="color: #FF0000">File is not an xml.</span><br />';
$uploadOk = 0;
}
if (file_exists($target_file)) {
echo '<span style="color: #FF0000">Sorry, <strong>'.$target_file.'</strong> already exists.</span><br />';
$uploadOk = 0;
}
if ($_FILES['fileToUpload']['size'][$i] > 50000000) {
echo '<span style="color: #FF0000">Sorry, your file is too large. Must be less than 50MG.</span><br />';
$uploadOk = 0;
}
if($fileType != 'xml') {
echo '<span style="color: #FF0000">Sorry, only XML files are allowed.</span><br />';
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo '<span style="color: #FF0000">Sorry, your file was not uploaded.</span><br />';
} else {
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'][$i], $target_file)) {
echo '<span style="color: #00AA00">The file '.basename($_FILES['fileToUpload']['name'][$i]).' has been uploaded.</span><br />';
} else {
echo '<span style="color: #FF0000">Sorry, there was an error uploading your file.</span><br />';
}
}
}
} ?>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr valign="top">
<td><input type="file" name="fileToUpload[]" id="fileToUpload[]" multiple></td>
</tr>
<tr valign="top">
<td><input type="submit" name="upload" id="upload" value="Upload XML"></td>
</tr>
</tbody>
</table></td>
<td valign="top"><strong>Uploaded Files List:</strong><br><?php
$int = 1;
foreach (new DirectoryIterator($directory) as $fileInfo) {
if($fileInfo->isDot()) continue;
$file = $fileInfo->getFilename();
echo $int.'. <a href="'.$directory.$file.'">'.$file.'</a><br />';
$int++;
} ?></td>
</tr>
</tbody>
</table>
</form>
答案 0 :(得分:0)
除了max_file_upload之外,还有另外两个涉及可能相关的文件上传的ini设置。
upload_max_filesize(默认为2 MB)限制每个文件的上传大小,post_max_size(默认为8 MB)限制POST内容的总大小,包括文件上传。
如果您遇到任何限制,可能会导致您看到的行为。
由于这两者在执行php代码之前都是相关的,因此您需要查看php.ini
(和/或.htaccess
设置(视情况而定)并确保它们被设置为允许接受所有POST内容的级别。