file upload problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahemeen
    New Member
    • Sep 2007
    • 11

    file upload problem

    Hi all.
    I have a page where I upload image file to web server and my code is as follows
    but when I upload it gives an error as follows:
    "Access to the path "D:\WEBDATA\... .\....." denied"

    [CODE=vbnet]
    If Not FileUpload1.Pos tedFile Is Nothing And FileUpload1.Pos tedFile.Content Length > 0 Then
    Dim fn As String = System.IO.Path. GetFileName(Fil eUpload1.Posted File.FileName)
    Dim SaveLocation As String = Server.MapPath( "Classified s") & "\" & fn
    Try
    FileUpload1.Pos tedFile.SaveAs( SaveLocation)
    lblRes.Text = "The file has been uploaded."
    Catch Exc As Exception
    lblRes.Text = "Error: " & Exc.Message
    End Try
    Else
    lblRes.Text = "Please select a file to upload."
    End If
    [/CODE]

    Please help me out to solve this problem and what changes I have to in the code.
    Last edited by Killer42; Nov 28 '07, 01:52 AM. Reason: Changed CODE tag to CODE=vbnet
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    You didn't tell us which line throws the error.

    Comment

    Working...