J
Jonathan
Hi everyone,
I have a problem with the file uploading in Asp.Net and I have read a lot
on forums on this but never found an answer. Here is the problem:
I know Asp.Net maximum Length for uploading a file to the server is 4Mo
but I changed that maximum to about 10Mo in my web.config file :
<httpRuntime executionTimeout="45" maxRequestLength="10000"
useFullyQualifiedRedirectUrl="true" />
Now, if i upload a 5Mo file to the server their won't be any problem but
if i upload a 12Mo file to the server, then i get to a File Not found
page. Even if i try to verify my length of file, i get an error. In this
example, the maximum the user can upload is 1Mo even if the
maxRequestLength in my Web.config file is set to 10Mo. Here is some code:
Dim intMaxLength As Integer = "1000000" 'bytes
If fil_Upload.PostedFile.ContentLength < intMaxLength Then
'Save uploaded file to server
Try
fil_Upload.PostedFile.SaveAs(Server.MapPath(".\mypath\" &
strFormatedName))
lab_Confirmation.ForeColor = System.Drawing.Color.Black
lab_Confirmation.Text = "Success"
Catch Exp as exception
lab_Confirmation.ForeColor = System.Drawing.Color.Red
lab_Confirmation.Text = "Error"
End Try
End If
If i had set my maxRequestLength to "5000" (5Mo) then every time i would
try to upload a file that is bigger then 5Mo, i would be redirected to a
File Not Found page (even if i have a length verification of under 1Mo!)
So, is there any way to prevent the user to try to upload a 60Mo,
70 Mo, 80Mo file to the server without having to set my maxRequestLength
to "60000","70000", "80000" and having to validate my ContentLength
before it is uploaded. In other words, can i set my maxRequestLength to
some maximum length and verify it before uploading the file to the
server.
Any help, article, thread, example, code, explanation is appreciated.
Thanx in advance.
Jonathan
I have a problem with the file uploading in Asp.Net and I have read a lot
on forums on this but never found an answer. Here is the problem:
I know Asp.Net maximum Length for uploading a file to the server is 4Mo
but I changed that maximum to about 10Mo in my web.config file :
<httpRuntime executionTimeout="45" maxRequestLength="10000"
useFullyQualifiedRedirectUrl="true" />
Now, if i upload a 5Mo file to the server their won't be any problem but
if i upload a 12Mo file to the server, then i get to a File Not found
page. Even if i try to verify my length of file, i get an error. In this
example, the maximum the user can upload is 1Mo even if the
maxRequestLength in my Web.config file is set to 10Mo. Here is some code:
Dim intMaxLength As Integer = "1000000" 'bytes
If fil_Upload.PostedFile.ContentLength < intMaxLength Then
'Save uploaded file to server
Try
fil_Upload.PostedFile.SaveAs(Server.MapPath(".\mypath\" &
strFormatedName))
lab_Confirmation.ForeColor = System.Drawing.Color.Black
lab_Confirmation.Text = "Success"
Catch Exp as exception
lab_Confirmation.ForeColor = System.Drawing.Color.Red
lab_Confirmation.Text = "Error"
End Try
End If
If i had set my maxRequestLength to "5000" (5Mo) then every time i would
try to upload a file that is bigger then 5Mo, i would be redirected to a
File Not Found page (even if i have a length verification of under 1Mo!)
So, is there any way to prevent the user to try to upload a 60Mo,
70 Mo, 80Mo file to the server without having to set my maxRequestLength
to "60000","70000", "80000" and having to validate my ContentLength
before it is uploaded. In other words, can i set my maxRequestLength to
some maximum length and verify it before uploading the file to the
server.
Any help, article, thread, example, code, explanation is appreciated.
Thanx in advance.
Jonathan