Connecting Tech Pros Worldwide Forums | Help | Site Map

Upload large data

=?Utf-8?B?SHVzYW0=?=
Guest
 
Posts: n/a
#1: Jun 27 '08
hi everybody:

I have the follwing code that I used it to upload data to my web site:

the code:

Sub SaveFile(ByVal file As HttpPostedFile)
Dim savePath As String =
Hosting.HostingEnvironment.ApplicationPhysicalPath + "UserArea\"
Dim fileName As String = FileUpload1.FileName
Dim pathToCheck As String = savePath + fileName
Dim tempfileName As String
' Check to see if a file already exists with the
' same name as the file to upload.
If (System.IO.File.Exists(pathToCheck)) Then
Dim counter As Integer = 2
While (System.IO.File.Exists(pathToCheck))
' If a file with this name already exists,
' prefix the filename with a number.
tempfileName = counter.ToString() + fileName
pathToCheck = savePath + tempfileName
counter = counter + 1
End While
fileName = tempfileName
' Notify the user that the file name was changed.
UploadStatusLabel.Text = "A file with the same name already
exists." + "<br>" + _
"Your file was saved as " + fileName
Else
' Notify the user that the file was saved successfully.
UploadStatusLabel.Text = "Your file was uploaded successfully."
End If
' Append the name of the file to upload to the path.
savePath += fileName
' Call the SaveAs method to save the uploaded
' file to the specified directory.
FileUpload1.SaveAs(savePath)
End Sub

And for button to upload this code:

If (FileUpload1.HasFile) Then
' Call a helper method routine to save the file.
SaveFile(FileUpload1.PostedFile)
Else
' Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "You did not specify a file to upload."
End If
and at web.Config I had that setting:

<httpRuntime executionTimeout="18000" maxRequestLength="2097151"/>

The problem is when I work with small data everthing is right but when I
work with data more than 200 mb like 345 mb I can not upload these data?

is there some one can help me or direct me abpout this situation?

any help will be appreciated regard's

Husam



Munna
Guest
 
Posts: n/a
#2: Jun 27 '08

re: Upload large data


On May 31, 9:42 am, Husam <Hu...@discussions.microsoft.comwrote:
Quote:
hi everybody:
>
I have the follwing code that I used it to upload data to my web site:
>
the code:
>
Sub SaveFile(ByVal file As HttpPostedFile)
Dim savePath As String =
Hosting.HostingEnvironment.ApplicationPhysicalPath + "UserArea\"
Dim fileName As String = FileUpload1.FileName
Dim pathToCheck As String = savePath + fileName
Dim tempfileName As String
' Check to see if a file already exists with the
' same name as the file to upload.
If (System.IO.File.Exists(pathToCheck)) Then
Dim counter As Integer = 2
While (System.IO.File.Exists(pathToCheck))
' If a file with this name already exists,
' prefix the filename with a number.
tempfileName = counter.ToString() + fileName
pathToCheck = savePath + tempfileName
counter = counter + 1
End While
fileName = tempfileName
' Notify the user that the file name was changed.
UploadStatusLabel.Text = "A file with the same name already
exists." + "<br>" + _
"Your file was saved as " + fileName
Else
' Notify the user that the file was saved successfully.
UploadStatusLabel.Text = "Your file was uploaded successfully."
End If
' Append the name of the file to upload to the path.
savePath += fileName
' Call the SaveAs method to save the uploaded
' file to the specified directory.
FileUpload1.SaveAs(savePath)
End Sub
>
And for button to upload this code:
>
If (FileUpload1.HasFile) Then
' Call a helper method routine to save the file.
SaveFile(FileUpload1.PostedFile)
Else
' Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "You did not specify a file to upload."
End If
and at web.Config I had that setting:
>
<httpRuntime executionTimeout="18000" maxRequestLength="2097151"/>
>
The problem is when I work with small data everthing is right but when I
work with data more than 200 mb like 345 mb I can not upload these data?
>
is there some one can help me or direct me abpout this situation?
>
any help will be appreciated regard's
>
Husam
Hi

Normally the max size of a httpwebupload is 4 mb and is defined in
machine.config file of webserver
to increase and override default the size of the maxrequest size go to
web.confiq just add
<httpRuntime maxRequestLength="1048576" /under system.web section

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Riki
Guest
 
Posts: n/a
#3: Jun 27 '08

re: Upload large data


Husam wrote:
Quote:
hi everybody:
>
I have the follwing code that I used it to upload data to my web site:
>
the code:
>
Sub SaveFile(ByVal file As HttpPostedFile)
Dim savePath As String =
Hosting.HostingEnvironment.ApplicationPhysicalPath + "UserArea\"
Dim fileName As String = FileUpload1.FileName
Dim pathToCheck As String = savePath + fileName
Dim tempfileName As String
' Check to see if a file already exists with the
' same name as the file to upload.
If (System.IO.File.Exists(pathToCheck)) Then
Dim counter As Integer = 2
While (System.IO.File.Exists(pathToCheck))
' If a file with this name already exists,
' prefix the filename with a number.
tempfileName = counter.ToString() + fileName
pathToCheck = savePath + tempfileName
counter = counter + 1
End While
fileName = tempfileName
' Notify the user that the file name was changed.
UploadStatusLabel.Text = "A file with the same name already
exists." + "<br>" + _
"Your file was saved as " +
fileName Else
' Notify the user that the file was saved successfully.
UploadStatusLabel.Text = "Your file was uploaded
successfully." End If
' Append the name of the file to upload to the path.
savePath += fileName
' Call the SaveAs method to save the uploaded
' file to the specified directory.
FileUpload1.SaveAs(savePath)
End Sub
>
And for button to upload this code:
>
If (FileUpload1.HasFile) Then
' Call a helper method routine to save the file.
SaveFile(FileUpload1.PostedFile)
Else
' Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "You did not specify a file to
upload." End If
and at web.Config I had that setting:
>
<httpRuntime executionTimeout="18000" maxRequestLength="2097151"/>
>
The problem is when I work with small data everthing is right but
when I work with data more than 200 mb like 345 mb I can not upload
these data?
>
is there some one can help me or direct me abpout this situation?
>
any help will be appreciated regard's
>
Husam
When web.config says that maxRequestLength="2097151" (bytes), it is normal
that the limit is 200MB.

--
Riki


Closed Thread