Upload large data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SHVzYW0=?=

    #1

    Upload large data

    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.Hosting Environment.App licationPhysica lPath + "UserArea\"
    Dim fileName As String = FileUpload1.Fil eName
    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(pathToC heck)) Then
    Dim counter As Integer = 2
    While (System.IO.File .Exists(pathToC heck))
    ' If a file with this name already exists,
    ' prefix the filename with a number.
    tempfileName = counter.ToStrin g() + fileName
    pathToCheck = savePath + tempfileName
    counter = counter + 1
    End While
    fileName = tempfileName
    ' Notify the user that the file name was changed.
    UploadStatusLab el.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.
    UploadStatusLab el.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.Sav eAs(savePath)
    End Sub

    And for button to upload this code:

    If (FileUpload1.Ha sFile) Then
    ' Call a helper method routine to save the file.
    SaveFile(FileUp load1.PostedFil e)
    Else
    ' Notify the user that a file was not uploaded.
    UploadStatusLab el.Text = "You did not specify a file to upload."
    End If
    and at web.Config I had that setting:

    <httpRuntime executionTimeou t="18000" maxRequestLengt h="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

    #2
    Re: Upload large data

    On May 31, 9:42 am, Husam <Hu...@discussi ons.microsoft.c omwrote:
    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.Hosting Environment.App licationPhysica lPath + "UserArea\"
    Dim fileName As String = FileUpload1.Fil eName
    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(pathToC heck)) Then
    Dim counter As Integer = 2
    While (System.IO.File .Exists(pathToC heck))
    ' If a file with this name already exists,
    ' prefix the filename with a number.
    tempfileName = counter.ToStrin g() + fileName
    pathToCheck = savePath + tempfileName
    counter = counter + 1
    End While
    fileName = tempfileName
    ' Notify the user that the file name was changed.
    UploadStatusLab el.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.
    UploadStatusLab el.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.Sav eAs(savePath)
    End Sub
    >
    And for button to upload this code:
    >
    If (FileUpload1.Ha sFile) Then
    ' Call a helper method routine to save the file.
    SaveFile(FileUp load1.PostedFil e)
    Else
    ' Notify the user that a file was not uploaded.
    UploadStatusLab el.Text = "You did not specify a file to upload."
    End If
    and at web.Config I had that setting:
    >
    <httpRuntime executionTimeou t="18000" maxRequestLengt h="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 maxRequestLengt h="1048576" /under system.web section

    Best of luck

    Munna



    Comment

    • Riki

      #3
      Re: Upload large data

      Husam wrote:
      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.Hosting Environment.App licationPhysica lPath + "UserArea\"
      Dim fileName As String = FileUpload1.Fil eName
      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(pathToC heck)) Then
      Dim counter As Integer = 2
      While (System.IO.File .Exists(pathToC heck))
      ' If a file with this name already exists,
      ' prefix the filename with a number.
      tempfileName = counter.ToStrin g() + fileName
      pathToCheck = savePath + tempfileName
      counter = counter + 1
      End While
      fileName = tempfileName
      ' Notify the user that the file name was changed.
      UploadStatusLab el.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.
      UploadStatusLab el.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.Sav eAs(savePath)
      End Sub
      >
      And for button to upload this code:
      >
      If (FileUpload1.Ha sFile) Then
      ' Call a helper method routine to save the file.
      SaveFile(FileUp load1.PostedFil e)
      Else
      ' Notify the user that a file was not uploaded.
      UploadStatusLab el.Text = "You did not specify a file to
      upload." End If
      and at web.Config I had that setting:
      >
      <httpRuntime executionTimeou t="18000" maxRequestLengt h="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 maxRequestLengt h="2097151" (bytes), it is normal
      that the limit is 200MB.

      --
      Riki


      Comment

      Working...