我们在 Mahara 网站上遇到问题,无论大小如何,我们都无法上传任何文件。
深入研究代码,$_FILES 数组返回以下内容:
Array
(
[userfile] => Array
(
[name] => Array
(
[0] => file.jpg
)
[type] => Array
(
[0] =>
)
[tmp_name] => Array
(
[0] =>
)
[error] => Array
(
[0] => 2
)
[size] => Array
(
[0] => 0
)
)
)
现在,我检查了我们的 php ini 设置(并检查了它们是否被应用于 phpinfo()):
我们有:
post_max_size 4000M
upload_max_filesize 4000M
文件上传开启
max_file_uploads 20
memory_limit 128M
最大执行时间 600
upload_tmp_dir "没有价值"
我不确定upload_tmp_dir 是否应该有一些东西,但是我们在这台服务器上运行了2 个网站,而另一个在上传文件时没有问题,所以我假设这不是问题。
据我所知,我们的服务器设置很好。
在表单的 HTML 中,它具有:
<div id="instconf_artefactid_upload_container" class="fileupload">
<input type="hidden" name="instconf_artefactid_uploadnumber" id="instconf_artefactid_uploadnumber" value="1"><input type="hidden" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="0">
<input type="hidden" name="MAX_FILE_SIZE" value="4194299904">
<div id="instconf_artefactid_upload_messages"></div>
<table class="fileuploadlicense"><tbody></tbody></table>
<div class="uploadform">
<label for="instconf_artefactid_userfile">Upload file</label>
<span id="instconf_artefactid_userfile_container"><input type="file" class="file" id="instconf_artefactid_userfile" name="userfile[]" multiple="" size="20"></span>
<span id="instconf_artefactid_userfile_maxuploadsize">(Maximum upload size 3.9GB)</span>
</div>
<div id="file_dropzone_container" class="instconf_artefactid">
<div id="fileDropzone" class="dropzone-previews" style="display:none;">
<div class="dz-message">Drop files here to upload</div>
</div>
</div>
<div class="uploadform">
<div id="instconf_artefactid_uploadsubmit_container">
<noscript>&lt;input type="submit" class="submit" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="Upload" /&gt;</noscript>
</div>
</div>
</div>
所以表单的 MAX_FILE_SIZE 为4194299904,但无论我尝试上传什么文件,即使它是一个大约 100 字节的 1 像素图像,我也会遇到同样的错误。
在我们所有运行在 CentOS 服务器上的 Mahara 实例上似乎都是一样的,但上传在我的 Windows localhost 上工作正常。
有谁知道这可能是什么原因造成的?
谢谢。
如果你想要完整的 HTML 表单,那就是:
<form class="pieform" name="instconf" method="post" action="" id="instconf" enctype="multipart/form-data">
<table cellspacing="0" border="0" class="maharatable"><tbody>
<tr id="instconf_title_header" class="text">
<th><label for="instconf_title">Block title</label></th>
</tr>
<tr id="instconf_title_container" class="text">
<td><input type="text" class="text autofocus" id="instconf_title" name="title" tabindex="0" maxlength="255" aria-describedby="" value="Image"></td>
</tr>
<tr id="instconf_artefactid_header" class="filebrowser">
<th><label for="instconf_artefactid">Image</label></th>
</tr>
<tr id="instconf_artefactid_container" class="filebrowser">
<td><p id="instconf_artefactid_empty_selectlist">No files found</p>
<table id="instconf_artefactid_selectlist" class="fullwidth hidden">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<input type="hidden" name="folder" id="instconf_artefactid_folder" value="0">
<input type="hidden" name="instconf_artefactid_changefolder" id="instconf_artefactid_changefolder" value="">
<input type="hidden" name="instconf_artefactid_foldername" id="instconf_artefactid_foldername" value="Home">
<div id="instconf_artefactid_open_upload_browse_container" class="hidden">
<input type="submit" class="buttondk" id="instconf_artefactid_open_upload_browse" name="browse" value="Select a file">
</div>
<div id="instconf_artefactid_upload_browse" class="upload_browse select">
<input type="hidden" name="instconf_artefactid_owner" id="instconf_artefactid_owner" value="user">
<input type="hidden" name="instconf_artefactid_ownerid" id="instconf_artefactid_ownerid" value="">
<input type="hidden" name="instconf_artefactid_changeowner" id="instconf_artefactid_changeowner" value="">
<div id="instconf_artefactid_ownertabs">
<ul class="artefactchooser-tabs files">
<li class="current"><a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;change=1&amp;action_configureblockinstance_id_30008=1&amp;owner=user">My files<span class="accessible-hidden">(tab selected)</span></a></li>
<li><a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;change=1&amp;action_configureblockinstance_id_30008=1&amp;owner=group">Group files<span class="accessible-hidden">(tab)</span></a></li>
<li><a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;change=1&amp;action_configureblockinstance_id_30008=1&amp;owner=institution">Institution files<span class="accessible-hidden">(tab)</span></a></li>
<li><a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;change=1&amp;action_configureblockinstance_id_30008=1&amp;owner=site">Site files<span class="accessible-hidden">(tab)</span></a></li>
</ul>
</div>
<div id="artefactchooser-body">
<div id="instconf_artefactid_ownersubtabs" class="hidden">
</div>
<div id="instconf_artefactid_upload_container" class="fileupload">
<input type="hidden" name="instconf_artefactid_uploadnumber" id="instconf_artefactid_uploadnumber" value="1"><input type="hidden" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="0">
<input type="hidden" name="MAX_FILE_SIZE" value="4194299904">
<div id="instconf_artefactid_upload_messages"></div>
<table class="fileuploadlicense"><tbody></tbody></table>
<div class="uploadform">
<label for="instconf_artefactid_userfile">Upload file</label>
<span id="instconf_artefactid_userfile_container"><input type="file" class="file" id="instconf_artefactid_userfile" name="userfile[]" multiple="" size="20"></span>
<span id="instconf_artefactid_userfile_maxuploadsize">(Maximum upload size 3.9GB)</span>
</div>
<div id="file_dropzone_container" class="instconf_artefactid">
<div id="fileDropzone" class="dropzone-previews" style="display:none;">
<div class="dz-message">Drop files here to upload</div>
</div>
</div>
<div class="uploadform">
<div id="instconf_artefactid_uploadsubmit_container">
<noscript>&lt;input type="submit" class="submit" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="Upload" /&gt;</noscript>
</div>
</div>
</div>
<div id="instconf_artefactid_upload_disabled" class="uploaddisabled hidden">You do not have permission to add content to this folder.</div>
<div id="instconf_artefactid_foldernav" class="foldernav">
Home
</div>
<div id="instconf_artefactid_filelist_container">
<table id="instconf_artefactid_filelist" class="tablerenderer filelist fullwidth">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Description</th>
<th class="filetags">Tags</th>
<th class="right"></th>
<th class="right nowrap">
<span class="accessible-hidden">Edit</span>
</th>
</tr>
</thead>
<tbody>
<tr id="file:1886" class="r0 directory-item folder">
<td class="icon-container">
<img src="http://mahara.bedford.ac.uk/theme/raw/static/images/folder.png">
</td>
<td class="filename">
<a href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&change=1&action_configureblockinstance_id_30008=1&folder=1886&owner=user" id="changefolder:1886" class="changefolder" title="Go to images">
<span class="accessible-hidden">Folder:</span>
<span class="display-title ">images</span>
</a>
</td>
<td class="filedescription">Image files</td>
<td class="filetags"></td>
<td class="right s nowrap">
<input type="submit" class="btn-big-edit tag-edit submit" name="instconf_artefactid_edit[1886]" value="Edit" title="Edit">
</td>
<!-- Ensure space for 3 buttons (in the case of a really long single line string in a user input field -->
<td class="right s nowrap">
</td>
</tr>
</tbody>
</table>
<p>
<a href="http://mahara.bedford.ac.uk/artefact/file/downloadfolder.php?folder=0">Download folder content as a zip file</a>
</p>
</div>
<table class="hidden">
<tbody id="instconf_artefactid_edit_placeholder">
<tr id="instconf_artefactid_edit_row" class="hidden editrow">
<td></td>
<td colspan="5" class="fileedittablewrap">
<table class="fileedittable">
<tbody>
<tr>
<th colspan="2" id="instconf_artefactid_edit_heading" class="fl">
</th>
</tr>
<tr class="required">
<th><label>Name</label> <span class="requiredmarker">*</span></th>
<td><input type="text" class="text" name="instconf_artefactid_edit_title" id="instconf_artefactid_edit_title" value="" size="40"></td>
</tr>
<tr>
<th><label>Description</label></th>
<td><input type="text" class="text" name="instconf_artefactid_edit_description" id="instconf_artefactid_edit_description" value="" size="40"></td>
</tr>
<tr class="tags">
<th><label>Tags</label></th>
<td>
<div><div><a href="">Show my tags</a></div><input name="instconf_artefactid_edit_tags" size="40" id="instconf_artefactid_edit_tags" value=""> <span class="help"><a href="" onclick="contextualHelp(null,null,"artefact","file",null,"tags",this); return false;"><img src="http://mahara.bedford.ac.uk/theme/raw/static/images/help.png" alt="Help" title="Help"></a></span></div>
<span> </span>
</td>
</tr>
<tr>
<td></td>
<td class="description">Enter comma-separated tags for this item. Items tagged with 'profile' are displayed in your sidebar.</td>
</tr>
<tr>
<th><label>Allow comments</label></th>
<td><input type="checkbox" name="instconf_artefactid_edit_allowcomments" id="instconf_artefactid_edit_allowcomments"></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" class="submit" name="instconf_artefactid_update[]" id="instconf_artefactid_edit_artefact" value="Save changes">
<input type="submit" class="cancel" name="instconf_artefactid_canceledit" id="instconf_artefactid_edit_cancel" value="Cancel">
</td>
</tr>
<tr><td colspan="2" id="instconf_artefactid_edit_messages"></td></tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
<tr id="instconf_showdescription_header" class="checkbox">
<th><label for="instconf_showdescription">Show description</label></th>
</tr>
<tr id="instconf_showdescription_container" class="checkbox">
<td><input type="checkbox" class="checkbox" id="instconf_showdescription" name="showdescription" tabindex="0" aria-describedby=""></td>
</tr>
<tr id="instconf_width_header" class="text">
<th><label for="instconf_width">Width</label></th>
</tr>
<tr id="instconf_width_container" class="text">
<td><input type="text" class="text" id="instconf_width" name="width" size="3" tabindex="0" aria-describedby="instconf_width_description " value=""></td>
</tr>
<tr class="text">
<td class="description"><span id="instconf_width_description">Specify the width for your image (in pixels). The image will be scaled to this width. Leave it blank to use the original size of the image. If the original size is too big, it will be scaled to the width of the block.</span></td>
</tr>
<tr id="instconf_retractable_header" class="checkbox">
<th><label for="instconf_retractable">Retractable</label></th>
</tr>
<tr id="instconf_retractable_container" class="checkbox">
<td><input type="checkbox" class="checkbox" id="instconf_retractable" name="retractable" tabindex="0" aria-describedby="instconf_retractable_description "></td>
</tr>
<tr class="checkbox">
<td class="description"><span id="instconf_retractable_description">Select to allow this block to be retracted when the header is clicked.</span></td>
</tr>
<tr id="instconf_retractedonload_header" class="checkbox">
<th><label for="instconf_retractedonload">Automatically retract</label></th>
</tr>
<tr id="instconf_retractedonload_container" class="checkbox">
<td><input type="checkbox" class="checkbox" id="instconf_retractedonload" name="retractedonload" tabindex="0" aria-describedby="instconf_retractedonload_description " disabled="disabled"></td>
</tr>
<tr class="checkbox">
<td class="description"><span id="instconf_retractedonload_description">Select to automatically retract this block.</span></td>
</tr>
<tr id="instconf_action_configureblockinstance_id_30008_container" class="submitcancel">
<td><input type="submit" class="submitcancel submit" id="instconf_action_configureblockinstance_id_30008" name="action_configureblockinstance_id_30008" tabindex="0" aria-describedby="" value="Save"> <input type="submit" class="submitcancel cancel" id="cancel_instconf_action_configureblockinstance_id_30008" name="cancel_action_configureblockinstance_id_30008" tabindex="0" aria-describedby="" value="Cancel"></td>
</tr>
</tbody></table>
<input type="hidden" class="hidden" id="instconf_blockconfig" name="blockconfig" aria-describedby="" value="30008">
<input type="hidden" class="hidden" id="instconf_id" name="id" aria-describedby="" value="5708">
<input type="hidden" class="hidden" id="instconf_change" name="change" aria-describedby="" value="1">
<input type="hidden" class="hidden" id="instconf_new" name="new" aria-describedby="" value="">
<input type="hidden" class="hidden" id="instconf_sesskey" name="sesskey" aria-describedby="" value="b6WAg98wGVcOer7x">
<input type="hidden" name="pieform_instconf" aria-describedby="" value="">
</form>