Web Connection
File size issue with GetMultipartFile
Gravatar is a globally recognized avatar based on your email address. File size issue with GetMultipartFile
  Stein Goering
  All
  Aug 20, 2021 @ 12:50pm

We've got a file upload method that's been part of our app for years, but we recently became aware that it is failing when trying to upload larger files. I'm aware of the 16 MB VFP string limit, but these are files in the 4-10 MB range. (The cutoff appears to be 4 MB.)

Here's the html used to launch the request:

<form id="form2" action="awupload.awp" enctype="multipart/form-data" name="Wwwebform" method="POST">
		 
... 
				<input type="file" name="txtFileName" id="txtFileName">
...

And the back end code:

    lcNameField ="txtFileName"
    lcFilename = ""
    lcFileBuffer = REQUEST.GetMultiPartFile(lcNameField,@lcFilename)
    IF LEN(lcFileBuffer) = 0
      lcTITLE = "Upload Error"
      lcMsg = lcFilename+": An error occurred during the upload or the file was too big."
    ENDIF

As I said, this works fine if the selected file is under 4 MB in size. But for anything larger, we just get empty values for both lcFileBuffer and lcFilename.

What can I do to make this work for larger files?

--stein

Gravatar is a globally recognized avatar based on your email address. re: File size issue with GetMultipartFile
  Stein Goering
  Rick Strahl
  Aug 21, 2021 @ 11:41am

I don't see an IIS error, but I went ahead and added that config setting:

        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="50000000" />
          </requestFiltering>
        </security>

That did not affect the behavior - I can still upload files smaller than 4 MB, but nothing larger.

However, I did notice something that may be of interest. All the systems where we've encountered the file size issue were running under the .NET Handler. The same code works fine for all file sizes on our demo site which is still using ISAPI. That might explain why we're just now getting complaints about this even though the feature has been in place for years, since we've recently started a push to move our legacy customer sites away from ISAPI.

Is there a .NET setting that might be impacting these upload requests?

--stein

Gravatar is a globally recognized avatar based on your email address. re: File size issue with GetMultipartFile
  Rick Strahl
  Stein Goering
  Aug 21, 2021 @ 01:36pm

There are two sets of settings in IIS: IIS and ASP.NET. Make sure you set both... as described in the link I posted.

The default ASP.NET request length in 4096kb (4mb) so this is likely your culprit.

This is 500mb:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <httpRuntime maxRequestLength="500000" executionTimeout="120" />
  </system.web>
</configuration>

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: File size issue with GetMultipartFile
  Stein Goering
  Rick Strahl
  Aug 21, 2021 @ 11:00pm

Thanks, that did it. And yes, I should have picked up from your article that both settings were needed.

Interesting to note that one setting is in bytes, the other in kilobytes.

--stein

© 1996-2024