Search code examples
htmlasp-classicweb-config

Limit the maximum size of video download


I'm downloading a video online and I want to limit the size allowed. I tried to add this to web.config

<httpRuntime executionTimeout ="3600" maxRequestLength ="2000" appRequestQueueLimit ="100" requestValidationMode ="2.0" requestLengthDiskThreshold ="2000000" /> 

But it does not work.

Here is my ASP code :

'Creation du Guid
Set TypeLib = Server.CreateObject("Scriptlet.TypeLib")
guid1 = TypeLib.Guid
guid1 = Left(guid1, Len(guid1)-2)
guid1 = replace(guid1, "{", "")
guid1 = replace(guid1, "}", "")
Set TypeLib = Nothing

'autoriser les mp4

set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.AllowedFilesList = "mp4"
mySmartUpload.DeniedFilesList = "bat,exe,com,asp,php,pdf,txt,doc,xls,jsp,aspx"
mySmartUpload.Upload
'chem="imagesCrop/"

ext1 = mySmartUpload.Files.Item(1).FileExt
video1 = cstr(guid1) & "." & ext1
set fichier1 = mySmartUpload.Files.Item(1)
fichier1.SaveAs(server.MapPath(chem) & "\" & video1)

set mySmartUpload = nothing

and my HTML input :

<input class="champ"  type="file" name="f1" >

Solution

  • You've got 2 solutions.

    In Web.config:

    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="104857600" />
        </requestFiltering>
      </security>
    </system.webServer>
    

    This will limit file upload size to 100 MB

    In SmartUpoad itself:

    mySmartUpload.MaxFileSize = 104857600
    

    That's 100 MB too.