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. Can not copy fie to the server.

Can not copy fie to the server.

Scheduled Pinned Locked Moved ASP.NET
htmlsysadminhelpquestion
2 Posts 2 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.
  • C Offline
    C Offline
    Chetan Ranpariya
    wrote on last edited by
    #1

    Hi Friends, I am have been facing a strange problem since long time. I have tried to find its solution from many places but I could not succeed. The problem is like following. I my web application I am providing facility to upload images to the server. I have managed to open the file open dialoge box using "File" control of html and get the select file path in a server side text. Now I am copyiny that file to the server by following code. FileInfo fImageFile = new FileInfo(txtCompImagePath.Text); if(fImageFile.Exists) { fImageFile.CopyTo(MapPath(ImageDirPath + "/"fImageFile.Name, true); } Everything works fine until user selects his image from the folder My Folder of from the Desktop. I mean when user select image from My Documents of from the Desktop the fImageFile.Exists returns false that means is tells that the file with specified path is not there. If user select image from any other folder from any drive it works fine and file copying goes smoothly but Images from My documents and Desktop folders could not be copied. and moreover I woder why is shows that the file doesnt exist while the file resides the physically. Can any please tell the cause and solution for this? Thanks to all of you in advance. Chetan Ranpariya

    T 1 Reply Last reply
    0
    • C Chetan Ranpariya

      Hi Friends, I am have been facing a strange problem since long time. I have tried to find its solution from many places but I could not succeed. The problem is like following. I my web application I am providing facility to upload images to the server. I have managed to open the file open dialoge box using "File" control of html and get the select file path in a server side text. Now I am copyiny that file to the server by following code. FileInfo fImageFile = new FileInfo(txtCompImagePath.Text); if(fImageFile.Exists) { fImageFile.CopyTo(MapPath(ImageDirPath + "/"fImageFile.Name, true); } Everything works fine until user selects his image from the folder My Folder of from the Desktop. I mean when user select image from My Documents of from the Desktop the fImageFile.Exists returns false that means is tells that the file with specified path is not there. If user select image from any other folder from any drive it works fine and file copying goes smoothly but Images from My documents and Desktop folders could not be copied. and moreover I woder why is shows that the file doesnt exist while the file resides the physically. Can any please tell the cause and solution for this? Thanks to all of you in advance. Chetan Ranpariya

      T Offline
      T Offline
      Tal Kain
      wrote on last edited by
      #2

      I am not familiar with the way you're uploading the files and the problems sounds really weird... but here is the best way to upload a file by using the FileUpload control: if (oFile.PostedFile != null) { string fullFileName = oFile.PostedFile.FileName; string fileName = System.IO.Path.GetFileName(fullFileName); oFile.PostedFile.SaveAs(Server.MapPath(string.Empty) + "\\" + fileName); } this code will upload the file to the requested directory... (you can easily change the saving directory by editing the parameter in the SaveAs function..) and it should work with no problems... Good luck, Tal Kain.

      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