title: PHP Upload error 2 (MAX_FILE_SIZE)
body: <p>We are having a problem on our Mahara websites, where we cannot upload any files, no matter what size.</p>
  
  <p>Digging into the code, the $_FILES array is returning this:</p>
  
  <pre><code>Array
  (
      [userfile] =&gt; Array
      (
          [name] =&gt; Array
              (
                  [0] =&gt; file.jpg
              )
  
          [type] =&gt; Array
              (
                  [0] =&gt; 
              )
  
          [tmp_name] =&gt; Array
              (
                  [0] =&gt; 
              )
  
          [error] =&gt; Array
              (
                  [0] =&gt; 2
              )
  
          [size] =&gt; Array
              (
                  [0] =&gt; 0
              )
  
      )
  </code></pre>
  
  <p>)</p>
  
  <p>Now, I've checked our php ini settings (and checked that they are being applied in phpinfo()):</p>
  
  <p>We have:</p>
  
  <p>post_max_size 4000M</p>
  
  <p>upload_max_filesize 4000M</p>
  
  <p>file_uploads On</p>
  
  <p>max_file_uploads 20</p>
  
  <p>memory_limit 128M</p>
  
  <p>max_execution_time 600</p>
  
  <p>upload_tmp_dir "no value"</p>
  
  <p>I am not sure if the upload_tmp_dir should have something, but we run 2 websites on this server and the other one is having no problem uploading files, so I'm assuming that's not the problem.</p>
  
  <p>So as far as I can see our server settings are fine.</p>
  
  <p>In the HTML of the form it has:</p>
  
  <pre><code>&lt;div id="instconf_artefactid_upload_container" class="fileupload"&gt;
    &lt;input type="hidden" name="instconf_artefactid_uploadnumber" id="instconf_artefactid_uploadnumber" value="1"&gt;&lt;input type="hidden" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="0"&gt;
    &lt;input type="hidden" name="MAX_FILE_SIZE" value="4194299904"&gt;
    &lt;div id="instconf_artefactid_upload_messages"&gt;&lt;/div&gt;
  
    &lt;table class="fileuploadlicense"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;
    &lt;div class="uploadform"&gt;
      &lt;label for="instconf_artefactid_userfile"&gt;Upload file&lt;/label&gt;
        &lt;span id="instconf_artefactid_userfile_container"&gt;&lt;input type="file" class="file" id="instconf_artefactid_userfile" name="userfile[]" multiple="" size="20"&gt;&lt;/span&gt;
        &lt;span id="instconf_artefactid_userfile_maxuploadsize"&gt;(Maximum upload size 3.9GB)&lt;/span&gt;
  
    &lt;/div&gt;
  
    &lt;div id="file_dropzone_container" class="instconf_artefactid"&gt;
        &lt;div id="fileDropzone" class="dropzone-previews" style="display:none;"&gt;
          &lt;div class="dz-message"&gt;Drop files here to upload&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="uploadform"&gt;
      &lt;div id="instconf_artefactid_uploadsubmit_container"&gt;
  
        &lt;noscript&gt;&amp;amp;lt;input type="submit" class="submit" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="Upload" /&amp;amp;gt;&lt;/noscript&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>So the form has the MAX_FILE_SIZE of <strong>4194299904</strong>, but no matter what file i try and upload, even if it's a 1-pixel image that's about 100 bytes, i get this same error.</p>
  
  <p>It seems to be the same on all our instances of Mahara, running on CentOS servers, but the uploads work fine on my Windows localhost.</p>
  
  <p>Does anyone know what might be causing this?</p>
  
  <p>Thanks.</p>
  
  <p>If you want the full form HTML, it's this:</p>
  
  <pre><code>    &lt;form class="pieform" name="instconf" method="post" action="" id="instconf" enctype="multipart/form-data"&gt;
  &lt;table cellspacing="0" border="0" class="maharatable"&gt;&lt;tbody&gt;
      &lt;tr id="instconf_title_header" class="text"&gt;
          &lt;th&gt;&lt;label for="instconf_title"&gt;Block title&lt;/label&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_title_container" class="text"&gt;
          &lt;td&gt;&lt;input type="text" class="text autofocus" id="instconf_title" name="title" tabindex="0" maxlength="255" aria-describedby="" value="Image"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_artefactid_header" class="filebrowser"&gt;
          &lt;th&gt;&lt;label for="instconf_artefactid"&gt;Image&lt;/label&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_artefactid_container" class="filebrowser"&gt;
          &lt;td&gt;&lt;p id="instconf_artefactid_empty_selectlist"&gt;No files found&lt;/p&gt;
  &lt;table id="instconf_artefactid_selectlist" class="fullwidth hidden"&gt;
   &lt;thead&gt;
    &lt;tr&gt;
     &lt;th&gt;&lt;/th&gt;
     &lt;th&gt;Name&lt;/th&gt;
     &lt;th&gt;Description&lt;/th&gt;
     &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
   &lt;/thead&gt;
   &lt;tbody&gt;
  
   &lt;/tbody&gt;
  &lt;/table&gt;
  
  
  
  
  
  &lt;input type="hidden" name="folder" id="instconf_artefactid_folder" value="0"&gt;
  &lt;input type="hidden" name="instconf_artefactid_changefolder" id="instconf_artefactid_changefolder" value=""&gt;
  &lt;input type="hidden" name="instconf_artefactid_foldername" id="instconf_artefactid_foldername" value="Home"&gt;
  
  &lt;div id="instconf_artefactid_open_upload_browse_container" class="hidden"&gt;
  &lt;input type="submit" class="buttondk" id="instconf_artefactid_open_upload_browse" name="browse" value="Select a file"&gt;
  &lt;/div&gt;
  
  
  &lt;div id="instconf_artefactid_upload_browse" class="upload_browse select"&gt;
  
  
  
  &lt;input type="hidden" name="instconf_artefactid_owner" id="instconf_artefactid_owner" value="user"&gt;
  &lt;input type="hidden" name="instconf_artefactid_ownerid" id="instconf_artefactid_ownerid" value=""&gt;
  &lt;input type="hidden" name="instconf_artefactid_changeowner" id="instconf_artefactid_changeowner" value=""&gt;
  &lt;div id="instconf_artefactid_ownertabs"&gt;
  &lt;ul class="artefactchooser-tabs files"&gt;
      &lt;li class="current"&gt;&lt;a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;amp;amp;change=1&amp;amp;amp;action_configureblockinstance_id_30008=1&amp;amp;amp;owner=user"&gt;My files&lt;span class="accessible-hidden"&gt;(tab selected)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;amp;amp;change=1&amp;amp;amp;action_configureblockinstance_id_30008=1&amp;amp;amp;owner=group"&gt;Group files&lt;span class="accessible-hidden"&gt;(tab)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;amp;amp;change=1&amp;amp;amp;action_configureblockinstance_id_30008=1&amp;amp;amp;owner=institution"&gt;Institution files&lt;span class="accessible-hidden"&gt;(tab)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a class="changeowner" href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;amp;amp;change=1&amp;amp;amp;action_configureblockinstance_id_30008=1&amp;amp;amp;owner=site"&gt;Site files&lt;span class="accessible-hidden"&gt;(tab)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  
  &lt;/ul&gt;
  
  &lt;/div&gt;
  &lt;div id="artefactchooser-body"&gt;
    &lt;div id="instconf_artefactid_ownersubtabs" class="hidden"&gt;
  
    &lt;/div&gt;
  
  
  &lt;div id="instconf_artefactid_upload_container" class="fileupload"&gt;
    &lt;input type="hidden" name="instconf_artefactid_uploadnumber" id="instconf_artefactid_uploadnumber" value="1"&gt;&lt;input type="hidden" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="0"&gt;
    &lt;input type="hidden" name="MAX_FILE_SIZE" value="4194299904"&gt;
    &lt;div id="instconf_artefactid_upload_messages"&gt;&lt;/div&gt;
  
    &lt;table class="fileuploadlicense"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;
    &lt;div class="uploadform"&gt;
      &lt;label for="instconf_artefactid_userfile"&gt;Upload file&lt;/label&gt;
        &lt;span id="instconf_artefactid_userfile_container"&gt;&lt;input type="file" class="file" id="instconf_artefactid_userfile" name="userfile[]" multiple="" size="20"&gt;&lt;/span&gt;
        &lt;span id="instconf_artefactid_userfile_maxuploadsize"&gt;(Maximum upload size 3.9GB)&lt;/span&gt;
  
    &lt;/div&gt;
  
    &lt;div id="file_dropzone_container" class="instconf_artefactid"&gt;
        &lt;div id="fileDropzone" class="dropzone-previews" style="display:none;"&gt;
          &lt;div class="dz-message"&gt;Drop files here to upload&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="uploadform"&gt;
      &lt;div id="instconf_artefactid_uploadsubmit_container"&gt;
  
        &lt;noscript&gt;&amp;amp;lt;input type="submit" class="submit" name="instconf_artefactid_upload" id="instconf_artefactid_upload" value="Upload" /&amp;amp;gt;&lt;/noscript&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;div id="instconf_artefactid_upload_disabled" class="uploaddisabled hidden"&gt;You do not have permission to add content to this folder.&lt;/div&gt;
  
  
  
  
  
  
  
  &lt;div id="instconf_artefactid_foldernav" class="foldernav"&gt;
  
        Home
  
  
  
  
  &lt;/div&gt;
  
  &lt;div id="instconf_artefactid_filelist_container"&gt;
  &lt;table id="instconf_artefactid_filelist" class="tablerenderer filelist fullwidth"&gt;
   &lt;thead&gt;
    &lt;tr&gt;
     &lt;th&gt;&lt;/th&gt;
     &lt;th&gt;Name&lt;/th&gt;
     &lt;th&gt;Description&lt;/th&gt;
  
       &lt;th class="filetags"&gt;Tags&lt;/th&gt;
  
       &lt;th class="right"&gt;&lt;/th&gt;
  
     &lt;th class="right nowrap"&gt;
         &lt;span class="accessible-hidden"&gt;Edit&lt;/span&gt;
     &lt;/th&gt;
    &lt;/tr&gt;
   &lt;/thead&gt;
   &lt;tbody&gt;
  
    &lt;tr id="file:1886" class="r0 directory-item folder"&gt;
      &lt;td class="icon-container"&gt;
                    &lt;img src="http://mahara.bedford.ac.uk/theme/raw/static/images/folder.png"&gt;
  
  
      &lt;/td&gt;
      &lt;td class="filename"&gt;
  
            &lt;a href="http://mahara.bedford.ac.uk/view/blocks.php?id=5708&amp;amp;change=1&amp;amp;action_configureblockinstance_id_30008=1&amp;amp;folder=1886&amp;amp;owner=user" id="changefolder:1886" class="changefolder" title="Go to images"&gt;
          &lt;span class="accessible-hidden"&gt;Folder:&lt;/span&gt;
          &lt;span class="display-title "&gt;images&lt;/span&gt;
      &lt;/a&gt;
  
      &lt;/td&gt;
      &lt;td class="filedescription"&gt;Image files&lt;/td&gt;
  
          &lt;td class="filetags"&gt;&lt;/td&gt;
  
          &lt;td class="right s nowrap"&gt;
                &lt;input type="submit" class="btn-big-edit tag-edit submit" name="instconf_artefactid_edit[1886]" value="Edit" title="Edit"&gt;
  
      &lt;/td&gt;
  
      &lt;!-- Ensure space for 3 buttons (in the case of a really long single line string in a user input field --&gt;
      &lt;td class="right s nowrap"&gt;
  
  
      &lt;/td&gt;
    &lt;/tr&gt;
  
  
   &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;p&gt;
    &lt;a href="http://mahara.bedford.ac.uk/artefact/file/downloadfolder.php?folder=0"&gt;Download folder content as a zip file&lt;/a&gt;
  &lt;/p&gt;
  
  
  &lt;/div&gt;
  
  &lt;table class="hidden"&gt;
    &lt;tbody id="instconf_artefactid_edit_placeholder"&gt;
      &lt;tr id="instconf_artefactid_edit_row" class="hidden editrow"&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td colspan="5" class="fileedittablewrap"&gt;
        &lt;table class="fileedittable"&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;th colspan="2" id="instconf_artefactid_edit_heading" class="fl"&gt;
  
              &lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr class="required"&gt;
              &lt;th&gt;&lt;label&gt;Name&lt;/label&gt; &lt;span class="requiredmarker"&gt;*&lt;/span&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input type="text" class="text" name="instconf_artefactid_edit_title" id="instconf_artefactid_edit_title" value="" size="40"&gt;&lt;/td&gt;
            &lt;/tr&gt;
                      &lt;tr&gt;
              &lt;th&gt;&lt;label&gt;Description&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input type="text" class="text" name="instconf_artefactid_edit_description" id="instconf_artefactid_edit_description" value="" size="40"&gt;&lt;/td&gt;
            &lt;/tr&gt;
  
            &lt;tr class="tags"&gt;
              &lt;th&gt;&lt;label&gt;Tags&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;
                &lt;div&gt;&lt;div&gt;&lt;a href=""&gt;Show my tags&lt;/a&gt;&lt;/div&gt;&lt;input name="instconf_artefactid_edit_tags" size="40" id="instconf_artefactid_edit_tags" value=""&gt; &lt;span class="help"&gt;&lt;a href="" onclick="contextualHelp(null,null,&amp;quot;artefact&amp;quot;,&amp;quot;file&amp;quot;,null,&amp;quot;tags&amp;quot;,this); return false;"&gt;&lt;img src="http://mahara.bedford.ac.uk/theme/raw/static/images/help.png" alt="Help" title="Help"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
                &lt;span&gt; &lt;/span&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td class="description"&gt;Enter comma-separated tags for this item. Items tagged with 'profile' are displayed in your sidebar.&lt;/td&gt;
            &lt;/tr&gt;
  
  
            &lt;tr&gt;
              &lt;th&gt;&lt;label&gt;Allow comments&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input type="checkbox" name="instconf_artefactid_edit_allowcomments" id="instconf_artefactid_edit_allowcomments"&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;
                &lt;input type="submit" class="submit" name="instconf_artefactid_update[]" id="instconf_artefactid_edit_artefact" value="Save changes"&gt;
                &lt;input type="submit" class="cancel" name="instconf_artefactid_canceledit" id="instconf_artefactid_edit_cancel" value="Cancel"&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;td colspan="2" id="instconf_artefactid_edit_messages"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;/tbody&gt;
  &lt;/table&gt;
  
  
  &lt;/div&gt;
  
  
  &lt;/div&gt;
  &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_showdescription_header" class="checkbox"&gt;
          &lt;th&gt;&lt;label for="instconf_showdescription"&gt;Show description&lt;/label&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_showdescription_container" class="checkbox"&gt;
          &lt;td&gt;&lt;input type="checkbox" class="checkbox" id="instconf_showdescription" name="showdescription" tabindex="0" aria-describedby=""&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_width_header" class="text"&gt;
          &lt;th&gt;&lt;label for="instconf_width"&gt;Width&lt;/label&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_width_container" class="text"&gt;
          &lt;td&gt;&lt;input type="text" class="text" id="instconf_width" name="width" size="3" tabindex="0" aria-describedby="instconf_width_description " value=""&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr class="text"&gt;
          &lt;td class="description"&gt;&lt;span id="instconf_width_description"&gt;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.&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_retractable_header" class="checkbox"&gt;
          &lt;th&gt;&lt;label for="instconf_retractable"&gt;Retractable&lt;/label&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_retractable_container" class="checkbox"&gt;
          &lt;td&gt;&lt;input type="checkbox" class="checkbox" id="instconf_retractable" name="retractable" tabindex="0" aria-describedby="instconf_retractable_description "&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr class="checkbox"&gt;
          &lt;td class="description"&gt;&lt;span id="instconf_retractable_description"&gt;Select to allow this block to be retracted when the header is clicked.&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_retractedonload_header" class="checkbox"&gt;
          &lt;th&gt;&lt;label for="instconf_retractedonload"&gt;Automatically retract&lt;/label&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_retractedonload_container" class="checkbox"&gt;
          &lt;td&gt;&lt;input type="checkbox" class="checkbox" id="instconf_retractedonload" name="retractedonload" tabindex="0" aria-describedby="instconf_retractedonload_description " disabled="disabled"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr class="checkbox"&gt;
          &lt;td class="description"&gt;&lt;span id="instconf_retractedonload_description"&gt;Select to automatically retract this block.&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="instconf_action_configureblockinstance_id_30008_container" class="submitcancel"&gt;
          &lt;td&gt;&lt;input type="submit" class="submitcancel submit" id="instconf_action_configureblockinstance_id_30008" name="action_configureblockinstance_id_30008" tabindex="0" aria-describedby="" value="Save"&gt; &lt;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"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  &lt;input type="hidden" class="hidden" id="instconf_blockconfig" name="blockconfig" aria-describedby="" value="30008"&gt;
  &lt;input type="hidden" class="hidden" id="instconf_id" name="id" aria-describedby="" value="5708"&gt;
  &lt;input type="hidden" class="hidden" id="instconf_change" name="change" aria-describedby="" value="1"&gt;
  &lt;input type="hidden" class="hidden" id="instconf_new" name="new" aria-describedby="" value=""&gt;
  &lt;input type="hidden" class="hidden" id="instconf_sesskey" name="sesskey" aria-describedby="" value="b6WAg98wGVcOer7x"&gt;
  &lt;input type="hidden" name="pieform_instconf" aria-describedby="" value=""&gt;
  &lt;/form&gt;
  </code></pre>