file upload control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shinis
    New Member
    • Jul 2008
    • 5

    file upload control

    I'm trying to add a file upload control to aspx page on my site, I've dragged the control onto the page and added a submit button beside it, the code for the button was this;

    I done it in asp.net with vb script

    FileUpload1.Sav eAs("C:\Documen ts and Settings\User\D esktop\New Folder" & FileUpload1.Fil eName)

    Now that worked fine, I tested the page and after clicking submit the file I specified was then inside this folder. But the I changed the code to this;

    FileUpload1.Sav eAs(http://www.mysite.com/test/Uploads/ & FileUpload1.Fil eName)

    All I done was changed it so it should save the file to a folder on my server instead of a folder on my computer but it didn't work

    It shows following error :

    The SaveAs method is configured to require a rooted path, and the path 'http://www.mysite.com/test/Uploads/enter.swf' is not rooted.

    How I understand it is I can only use the 'SaveAs' function if the file is to stay on a computer, I can't use it to save the file on a server.
    How do I get around this so the files my visitors upload will be saved in the Uploads folder on my server?

    I'd really appreciate some help with this as I'm completely stumped.

    Kind Regards
    Shini
  • vinot85
    New Member
    • Aug 2007
    • 53

    #2
    All you have done is right,

    In order to save a file at Server, you should use like,

    file1.SaveAs(Se rver.MapPath("\ Uploads\" & file1.name & ".jpg"))

    This Server.MapPath( ) method will map your application to correct virtual path where your application is running.

    Now ur files will be saved at dir called "Uploads" in your virtual directory.

    Make sure that enc-type attribute of your web form is having the value
    "multipart-form/data"

    Regards,

    Vinoth

    Comment

    • Shinis
      New Member
      • Jul 2008
      • 5

      #3
      Thank you Vinoth......... .........

      Comment

      Working...