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. How to use FileUpload

How to use FileUpload

Scheduled Pinned Locked Moved ASP.NET
sysadmintutorial
8 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.
  • M Offline
    M Offline
    Muhammad Gouda
    wrote on last edited by
    #1

    I am using the FileUpload control to upload files from client's local HDD to the server But the code always searches for the file path on the server side e.g. If the user tried to upload a file C:\1.txt from his machine, He gets an exception "Could not find file C:\1.txt" But if there is a file with the same path on the server it works and upload the server file instead How can work around that

    foreach(Minute m in MyLife) myExperience++;

    N M M 3 Replies Last reply
    0
    • M Muhammad Gouda

      I am using the FileUpload control to upload files from client's local HDD to the server But the code always searches for the file path on the server side e.g. If the user tried to upload a file C:\1.txt from his machine, He gets an exception "Could not find file C:\1.txt" But if there is a file with the same path on the server it works and upload the server file instead How can work around that

      foreach(Minute m in MyLife) myExperience++;

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Mohammed Gouda wrote:

      But the code always searches for the file path on the server side

      Your code is broken. Post the code which you are using for upload.

      Navaneeth How to use google | Ask smart questions

      A 1 Reply Last reply
      0
      • N N a v a n e e t h

        Mohammed Gouda wrote:

        But the code always searches for the file path on the server side

        Your code is broken. Post the code which you are using for upload.

        Navaneeth How to use google | Ask smart questions

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        Hey, Navaneeth, Wishing You and Your Family A Very Happy and Prosperous New Year !!!

        cheers, Abhijit

        N 1 Reply Last reply
        0
        • A Abhijit Jana

          Hey, Navaneeth, Wishing You and Your Family A Very Happy and Prosperous New Year !!!

          cheers, Abhijit

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Thanks :) and wishing you too. 4 hours to go!

          Navaneeth How to use google | Ask smart questions

          A 1 Reply Last reply
          0
          • M Muhammad Gouda

            I am using the FileUpload control to upload files from client's local HDD to the server But the code always searches for the file path on the server side e.g. If the user tried to upload a file C:\1.txt from his machine, He gets an exception "Could not find file C:\1.txt" But if there is a file with the same path on the server it works and upload the server file instead How can work around that

            foreach(Minute m in MyLife) myExperience++;

            M Offline
            M Offline
            MarcelloTurnbull
            wrote on last edited by
            #5

            What is the .NET Framework version ?

            M 1 Reply Last reply
            0
            • M MarcelloTurnbull

              What is the .NET Framework version ?

              M Offline
              M Offline
              MarcelloTurnbull
              wrote on last edited by
              #6

              What is the .NET framework version ? Marcello Turnbull

              1 Reply Last reply
              0
              • M Muhammad Gouda

                I am using the FileUpload control to upload files from client's local HDD to the server But the code always searches for the file path on the server side e.g. If the user tried to upload a file C:\1.txt from his machine, He gets an exception "Could not find file C:\1.txt" But if there is a file with the same path on the server it works and upload the server file instead How can work around that

                foreach(Minute m in MyLife) myExperience++;

                M Offline
                M Offline
                Muhammad Gouda
                wrote on last edited by
                #7

                Thanks to all participants I solved it I had a server side method as follows

                AddAttachment(string filePath)
                {
                //here is the source of exception
                FileStream fs = new FileStream(filePath, FileMode.Open);
                //Then I get the data in fs in the form of byte []
                }

                To solve the problem, I changed the method to

                AddAttachment(byte [] fileContents)
                {
                //Then I get the data in fileContents directly
                //where fileContent is obtained from the FileUpload control
                }

                foreach(Minute m in MyLife) myExperience++;

                1 Reply Last reply
                0
                • N N a v a n e e t h

                  Thanks :) and wishing you too. 4 hours to go!

                  Navaneeth How to use google | Ask smart questions

                  A Offline
                  A Offline
                  Abhijit Jana
                  wrote on last edited by
                  #8

                  N a v a n e e t h wrote:

                  Thanks Smile and wishing you too.

                  Thanks Man !!!

                  N a v a n e e t h wrote:

                  4 hours to go!

                  Ya!!! But Still Hanging in Office :( Hope tonight have a party !!! :beer: Enjoy !!!

                  cheers, Abhijit

                  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