Index: index.php
===================================================================
RCS file: /cvsroot/moodle/moodle/files/index.php,v
retrieving revision 1.125
diff -u -r1.125 index.php
--- index.php	4 Apr 2008 02:54:27 -0000	1.125
+++ index.php	5 May 2008 23:56:23 -0000
@@ -201,6 +201,14 @@
                 // um will take care of error reporting.
                 displaydir($wdir);
             } else {
+
+                if ($_SERVER['REQUEST_METHOD'] === 'POST' and !count($_POST)) {
+                    /*  This situation is likely the result of the user
+                        attempting to upload a file larger than POST_MAX_SIZE
+                        See bug MDL-14000 */
+                    notify(get_string('uploadserverlimit'));
+                }
+
                 $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
                 $filesize = display_size($upload_max_filesize);
 
@@ -209,14 +217,16 @@
                 $strmaxsize = get_string("maxsize", "", $filesize);
                 $strcancel = get_string("cancel");
 
+                /*  Create form action - See MDL-14000
+                    It is necessary to send these details via GET as if the user
+                    submits a file larger than POST_MAX_SIZE, all post data will
+                    be lost. */
+                $frm_action = $CFG->wwwroot."/files/index.php?choose=$choose&id=$id&wdir=".urlencode($wdir)."&action=upload";
+
                 echo "<p>$struploadafile ($strmaxsize) --> <b>$wdir</b></p>";
-                echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"index.php\">";
+                echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"$frm_action\">";
                 echo "<div>";
                 echo "<table><tr><td colspan=\"2\">";
-                echo ' <input type="hidden" name="choose" value="'.$choose.'" />';
-                echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
-                echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
-                echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />";
                 echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
                 upload_print_form_fragment(1,array('userfile'),null,false,null,$upload_max_filesize,0,false);
                 echo " </td></tr></table>";

