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. Cannot use a leading .. to exit above the top directory.

Cannot use a leading .. to exit above the top directory.

Scheduled Pinned Locked Moved ASP.NET
sysadmin
4 Posts 3 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.
  • B Offline
    B Offline
    benams
    wrote on last edited by
    #1

    I get the exception : Cannot use a leading .. to exit above the top directory. when I try to save a picture to the server, I use the line:

    fupPicSummary.PostedFile.SaveAs(Server.MapPath(@"../Pictures/summary_" + campaign.ID + ".jpg"));

    N 1 Reply Last reply
    0
    • B benams

      I get the exception : Cannot use a leading .. to exit above the top directory. when I try to save a picture to the server, I use the line:

      fupPicSummary.PostedFile.SaveAs(Server.MapPath(@"../Pictures/summary_" + campaign.ID + ".jpg"));

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      If the Pictures folder is under the root folder of your web application than this exception will be thrown. The ../ is attempting to go above the root folder, which is not allowed.


      I know the language. I've read a book. - _Madmatt

      B 1 Reply Last reply
      0
      • N Not Active

        If the Pictures folder is under the root folder of your web application than this exception will be thrown. The ../ is attempting to go above the root folder, which is not allowed.


        I know the language. I've read a book. - _Madmatt

        B Offline
        B Offline
        benams
        wrote on last edited by
        #3

        the pictures folder under a sub-domain. can I access it somehow else than full physical type?

        Y 1 Reply Last reply
        0
        • B benams

          the pictures folder under a sub-domain. can I access it somehow else than full physical type?

          Y Offline
          Y Offline
          Yuri Vital
          wrote on last edited by
          #4

          You have to use the tilde character "~" to specify a path who start from the root of your web app. the code will be :

          fupPicSummary.PostedFile.SaveAs(Server.MapPath(@"~/Pictures/summary_" + campaign.ID + ".jpg"));

          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