2

Is there any way to set the max file limit. I already searched google and found this code (this code isnt working):

function addFile() {
clickFirstOnEnter('dlgAddFile');

var dialogButtons = {};
dialogButtons[t('Upload')] = function () {
var maxtotal = RoxyFilemanConf.MAXTOTAL;
var maxfilesize = RoxyFilemanConf.MAXFILESIZE;
var fileoversize = "";
var totalsize = 0;
if (!$('#fileUploads').val())
alert(t('E_SelectFiles'));
else {
if (!RoxyFilemanConf.UPLOAD) {
alert(t('E_ActionDisabled'));
//$('#dlgAddFile').dialog('close');
}
else {
var files = $('#fileUploads')[0].files;
for (var i = 0; i < files.length; i++) {
//alert(files[i].name);
totalsize += files[i].size;
if ((files[i].size / 1024) > maxfilesize) {
fileoversize = files[i].name + '\n';
}
}

if ((totalsize / 1024 / 1024) > maxtotal) {
alert(t('E_MAXSIZE') + ". Set to " + maxsize + "MB.");
}
else if (fileoversize != "") {
alert("Max total upload : "+ maxfilesize +"KB. Oversized files:\n" + fileoversize);
}
else {
document.forms['addfile'].action = RoxyFilemanConf.UPLOAD;
document.forms['addfile'].submit();
}
}
}
};
dialogButtons[t('Cancel')] = function () { $('#dlgAddFile').dialog('close'); };

$('#dlgAddFile').dialog({ title: t('T_AddFile'), modal: true, buttons: dialogButtons });
}

Adding 2 variables to conf.json
MAXTOTAL and MAXFILESIZE. 

but this doesnt work at all.. Anyone who got any suggestions/solution for this problem?

halfer
  • 19,471
  • 17
  • 87
  • 173
E3Im
  • 340
  • 2
  • 17

2 Answers2

2

As OP has already discovered, this is a configuration setting. For people searching for a solution in .Net, two changes are required in the web.config for IIS 7.0+. Check the link for more complete details.

I added the elements to my root web.config.

<system.web>
    <!-- Max int value of 2gb --> 
    <httpRuntime maxRequestLength="2097151" appRequestQueueLimit="100000" requestLengthDiskThreshold="2097151" />    
</system.web>
<system.webServer>
     <security> 
        <requestFiltering> 
            <!-- maxAllowedContentLength, for IIS, in bytes --> 
            <requestLimits maxAllowedContentLength="104857600" ></requestLimits>
        </requestFiltering> 
    </security>
</system.webServer>

Sause: How to increase the max upload file size in ASP.NET?

I've also updated the code to work as intended with version 1.4.5. Make sure you apply this to the main.js/main.min.js files.

function addFile() {
    clickFirstOnEnter("dlgAddFile");
    $("#uploadResult").html("");
    clearFileField();
    var a = {};
    a[t("Upload")] = {
        id: "btnUpload",
        text: t("Upload"),
        disabled: true,
        click: function () {
            if (!$("#fileUploads").val() && (!uploadFileList || uploadFileList.length == 0)) {
                alert(t("E_SelectFiles"))
            } else {
                if (!RoxyFilemanConf.UPLOAD) {
                    alert(t("E_ActionDisabled"))
                } else {
                    // start of change
                    var maxtotal = RoxyFilemanConf.MAXTOTAL;
                    var maxfilesize = RoxyFilemanConf.MAXFILESIZE;
                    var fileoversize = "";
                    var totalsize = 0;

                    for (var i = 0; i < uploadFileList.length; i++) {
                        totalsize += uploadFileList[i].size;
                        if ((uploadFileList[i].size / 1024) > maxfilesize) {
                            fileoversize = fileoversize + uploadFileList[i].name + '\n';
                        }
                    }

                    if ((totalsize / 1024 / 1024) > maxtotal) {
                        alert(t('E_MAXSIZE') + ". Set to " + maxsize + "MB.");
                    } else if (fileoversize != "") {
                        alert("Max total upload : " + maxfilesize + "KB. Oversized files:\n" + fileoversize);

                    } else // end of change
                    if (window.FormData && window.XMLHttpRequest && window.FileList && uploadFileList && uploadFileList.length > 0) 
                    {
                        for (i = 0; i < uploadFileList.length; i++) {
                            fileUpload(uploadFileList[i], i)
                        }
                    } else {
                        document.forms.addfile.action = RoxyFilemanConf.UPLOAD;
                        document.forms.addfile.submit()
                    }
                }
            }
        }
    };
    a[t("Cancel")] = function () {
        $("#dlgAddFile").dialog("close")
    };
    $("#dlgAddFile").dialog({
        title: t("T_AddFile"),
        modal: true,
        buttons: a,
        width: 400
    })
}
Community
  • 1
  • 1
JoeF
  • 633
  • 7
  • 12
0

(Posted on behalf of the OP).

This is fixed. I found out that the max file is going through the php.ini.

upload_max_filesize=4M
halfer
  • 19,471
  • 17
  • 87
  • 173