Fixes to increase the number of options available to limit assignment

upload size, and also to limit the list based on PHP limits
This commit is contained in:
moodler 2002-11-28 02:41:56 +00:00
parent f42cf95f3c
commit 64efda84b5
2 changed files with 14 additions and 8 deletions

View File

@ -1766,8 +1766,10 @@ function get_real_size($size=0) {
return 0;
}
$scan['MB'] = 1048576;
$scan['Mb'] = 1048576;
$scan['M'] = 1048576;
$scan['KB'] = 1024;
$scan['Kb'] = 1024;
$scan['K'] = 1024;
while (list($key) = each($scan)) {

View File

@ -75,15 +75,19 @@
<td align=right><P><B><? print_string("maximumsize", "assignment") ?>:</B></P></TD>
<td>
<?
$filesize[10000] = "10kb";
$filesize[50000] = "50kb";
$filesize[100000] = "100kb";
$filesize[500000] = "500kb";
$filesize[1000000] = "1000Kb (1Mb)";
$filesize[2000000] = "2000Kb (2Mb)";
if (!$form->maxbytes) {
$form->maxbytes = 500000;
$sizelist = array("10Kb", "50Kb", "100Kb", "500Kb", "1Mb", "2Mb", "5Mb", "10Mb", "20Mb", "50Mb");
$maxsize = get_max_upload_file_size();
foreach ($sizelist as $size) {
$sizebytes = get_real_size($size);
if ($sizebytes < $maxsize) {
$filesize[$sizebytes] = $size;
}
}
$filesize[$maxsize] = display_size($maxsize);
if (!$form->maxbytes) {
$form->maxbytes = get_real_size("500K");
}
ksort($filesize, SORT_NUMERIC);
choose_from_menu($filesize, "maxbytes", "$form->maxbytes");
?>
</td>