Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need help to upload 500 MB file on FTP

Need help to upload 500 MB file on FTP

Scheduled Pinned Locked Moved ASP.NET
helpsysadmin
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    silentspeaker
    wrote on last edited by
    #1

    I am having problem in Uploading 500 MB File on web server can anyone help me

    Private Function UploadToFTP(ByVal fileToUpload As HttpPostedFile) As Boolean

    Try
    Dim uploadUrl As String = "ftp://........................."
    Dim uploadFileName As String = fileToUpload.FileName

    Dim streamObj As Stream = fileToUpload.InputStream
    Dim buffer As [Byte]() = New [Byte](fileToUpload.ContentLength - 1) {}
    streamObj.Read(buffer, 0, buffer.Length)
    streamObj.Close()
    streamObj = Nothing

    Dim ftpUrl As String = String.Format("{0}/{1}", uploadUrl, uploadFileName)
    Dim requestObj As FtpWebRequest = TryCast(FtpWebRequest.Create(ftpUrl), FtpWebRequest)
    requestObj.Method = WebRequestMethods.Ftp.UploadFile
    requestObj.Credentials = New NetworkCredential("UserID", "Password")
    Dim requestStream As Stream = requestObj.GetRequestStream()
    requestStream.Write(buffer, 0, buffer.Length)
    requestStream.Flush()
    requestStream.Close()
    requestObj = Nothing

    Return True
    Catch ex As Exception
    Return False
    End Try
    End Function

    Richard DeemingR J X 3 Replies Last reply
    0
    • S silentspeaker

      I am having problem in Uploading 500 MB File on web server can anyone help me

      Private Function UploadToFTP(ByVal fileToUpload As HttpPostedFile) As Boolean

      Try
      Dim uploadUrl As String = "ftp://........................."
      Dim uploadFileName As String = fileToUpload.FileName

      Dim streamObj As Stream = fileToUpload.InputStream
      Dim buffer As [Byte]() = New [Byte](fileToUpload.ContentLength - 1) {}
      streamObj.Read(buffer, 0, buffer.Length)
      streamObj.Close()
      streamObj = Nothing

      Dim ftpUrl As String = String.Format("{0}/{1}", uploadUrl, uploadFileName)
      Dim requestObj As FtpWebRequest = TryCast(FtpWebRequest.Create(ftpUrl), FtpWebRequest)
      requestObj.Method = WebRequestMethods.Ftp.UploadFile
      requestObj.Credentials = New NetworkCredential("UserID", "Password")
      Dim requestStream As Stream = requestObj.GetRequestStream()
      requestStream.Write(buffer, 0, buffer.Length)
      requestStream.Flush()
      requestStream.Close()
      requestObj = Nothing

      Return True
      Catch ex As Exception
      Return False
      End Try
      End Function

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You're missing a call to GetResponse on the FtpWebRequest instance. The request won't be sent until you call GetResponse.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      S 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        You're missing a call to GetResponse on the FtpWebRequest instance. The request won't be sent until you call GetResponse.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        S Offline
        S Offline
        silentspeaker
        wrote on last edited by
        #3

        what is it

        Richard DeemingR 1 Reply Last reply
        0
        • S silentspeaker

          what is it

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          silentspeaker wrote:

          what is it

          What is what? :confused:


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          S 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            silentspeaker wrote:

            what is it

            What is what? :confused:


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            S Offline
            S Offline
            silentspeaker
            wrote on last edited by
            #5

            I dont know how to add it. Need assistance here

            Richard DeemingR 1 Reply Last reply
            0
            • S silentspeaker

              I dont know how to add it. Need assistance here

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Something like this:

              Private Function UploadToFTP(ByVal fileToUpload As HttpPostedFile) As Boolean
              Try
              Dim uploadUrl As String = "ftp://........................."
              Dim uploadFileName As String = fileToUpload.FileName

                Using streamObj As Stream = fileToUpload.InputStream
                   Dim buffer As \[Byte\]() = New \[Byte\](fileToUpload.ContentLength - 1) {}
                   streamObj.Read(buffer, 0, buffer.Length)
                End Using
                
                Dim ftpUrl As String = String.Format("{0}/{1}", uploadUrl, uploadFileName)
                Dim requestObj As FtpWebRequest = TryCast(FtpWebRequest.Create(ftpUrl), FtpWebRequest)
                requestObj.Method = WebRequestMethods.Ftp.UploadFile
                requestObj.Credentials = New NetworkCredential("UserID", "Password")
                
                Using requestStream As Stream = requestObj.GetRequestStream()
                   requestStream.Write(buffer, 0, buffer.Length)
                   requestStream.Flush()
                End Using
                
                Using responseObj As FtpWebResponse = TryCast(requestObj.GetResponse(), FtpWebResponse)
                   ' TODO: Look at responseObj.StatusCode to see if the upload succeeded
                End Using
                
                Return True
              

              Catch ex As Exception
              Return False
              End Try
              End Function


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              S 1 Reply Last reply
              0
              • Richard DeemingR Richard Deeming

                Something like this:

                Private Function UploadToFTP(ByVal fileToUpload As HttpPostedFile) As Boolean
                Try
                Dim uploadUrl As String = "ftp://........................."
                Dim uploadFileName As String = fileToUpload.FileName

                  Using streamObj As Stream = fileToUpload.InputStream
                     Dim buffer As \[Byte\]() = New \[Byte\](fileToUpload.ContentLength - 1) {}
                     streamObj.Read(buffer, 0, buffer.Length)
                  End Using
                  
                  Dim ftpUrl As String = String.Format("{0}/{1}", uploadUrl, uploadFileName)
                  Dim requestObj As FtpWebRequest = TryCast(FtpWebRequest.Create(ftpUrl), FtpWebRequest)
                  requestObj.Method = WebRequestMethods.Ftp.UploadFile
                  requestObj.Credentials = New NetworkCredential("UserID", "Password")
                  
                  Using requestStream As Stream = requestObj.GetRequestStream()
                     requestStream.Write(buffer, 0, buffer.Length)
                     requestStream.Flush()
                  End Using
                  
                  Using responseObj As FtpWebResponse = TryCast(requestObj.GetResponse(), FtpWebResponse)
                     ' TODO: Look at responseObj.StatusCode to see if the upload succeeded
                  End Using
                  
                  Return True
                

                Catch ex As Exception
                Return False
                End Try
                End Function


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                S Offline
                S Offline
                silentspeaker
                wrote on last edited by
                #7

                HTTP Error 404.13 - Not Found
                The request filtering module is configured to deny a request that exceeds the request content length.

                Richard DeemingR 1 Reply Last reply
                0
                • S silentspeaker

                  HTTP Error 404.13 - Not Found
                  The request filtering module is configured to deny a request that exceeds the request content length.

                  Richard DeemingR Offline
                  Richard DeemingR Offline
                  Richard Deeming
                  wrote on last edited by
                  #8

                  That's not a problem uploading the file to the FTP site; it's a problem uploading the file to your ASP.NET page. You'll need to change the IIS configuration to allow large uploads. http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx[^]


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                  1 Reply Last reply
                  0
                  • S silentspeaker

                    I am having problem in Uploading 500 MB File on web server can anyone help me

                    Private Function UploadToFTP(ByVal fileToUpload As HttpPostedFile) As Boolean

                    Try
                    Dim uploadUrl As String = "ftp://........................."
                    Dim uploadFileName As String = fileToUpload.FileName

                    Dim streamObj As Stream = fileToUpload.InputStream
                    Dim buffer As [Byte]() = New [Byte](fileToUpload.ContentLength - 1) {}
                    streamObj.Read(buffer, 0, buffer.Length)
                    streamObj.Close()
                    streamObj = Nothing

                    Dim ftpUrl As String = String.Format("{0}/{1}", uploadUrl, uploadFileName)
                    Dim requestObj As FtpWebRequest = TryCast(FtpWebRequest.Create(ftpUrl), FtpWebRequest)
                    requestObj.Method = WebRequestMethods.Ftp.UploadFile
                    requestObj.Credentials = New NetworkCredential("UserID", "Password")
                    Dim requestStream As Stream = requestObj.GetRequestStream()
                    requestStream.Write(buffer, 0, buffer.Length)
                    requestStream.Flush()
                    requestStream.Close()
                    requestObj = Nothing

                    Return True
                    Catch ex As Exception
                    Return False
                    End Try
                    End Function

                    J Offline
                    J Offline
                    jkirkerx
                    wrote on last edited by
                    #9

                    You need to tell us what web server your using, IIS6 requires the metabase editor to change one of the values, I think max request length, under IIS/Defaults. So you can change the value in Web.config, but the metabase supersedes the web.config overall. IIS7 was a e bit easier it doesn't use metabase, there's a config file in IISAdmin folder, in system32, that you just edit. After you edit it, I think it changes a more complex structure in the background. [Edit] I messed with the upload limit for years, and tried everything, but the limit is the limit. I'm not sure about FTP, I have changed my servers to 1 gig, which is the limit for Server 2003, but you have to login to do it. I ended up using Uploadify, which works pretty good. The metabase editor is available in the IIS resource kit, an old download from microsoft.

                    1 Reply Last reply
                    0
                    • S silentspeaker

                      I am having problem in Uploading 500 MB File on web server can anyone help me

                      Private Function UploadToFTP(ByVal fileToUpload As HttpPostedFile) As Boolean

                      Try
                      Dim uploadUrl As String = "ftp://........................."
                      Dim uploadFileName As String = fileToUpload.FileName

                      Dim streamObj As Stream = fileToUpload.InputStream
                      Dim buffer As [Byte]() = New [Byte](fileToUpload.ContentLength - 1) {}
                      streamObj.Read(buffer, 0, buffer.Length)
                      streamObj.Close()
                      streamObj = Nothing

                      Dim ftpUrl As String = String.Format("{0}/{1}", uploadUrl, uploadFileName)
                      Dim requestObj As FtpWebRequest = TryCast(FtpWebRequest.Create(ftpUrl), FtpWebRequest)
                      requestObj.Method = WebRequestMethods.Ftp.UploadFile
                      requestObj.Credentials = New NetworkCredential("UserID", "Password")
                      Dim requestStream As Stream = requestObj.GetRequestStream()
                      requestStream.Write(buffer, 0, buffer.Length)
                      requestStream.Flush()
                      requestStream.Close()
                      requestObj = Nothing

                      Return True
                      Catch ex As Exception
                      Return False
                      End Try
                      End Function

                      X Offline
                      X Offline
                      xut2447
                      wrote on last edited by
                      #10

                      you can try to use OCX

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups