Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am doing a project, there is an image upload process in it,
i use the following code
=========================================================================
VB
Public Function UploadThisFile(ByVal upload As FileUpload)

            Dim theFilename As String
            Dim str_Custfilename As String
            If upload.HasFile Then
                str_Custfilename = upload.FileName
                theFilename = Path.Combine(HttpContext.Current.Server.MapPath("~/uploadedimages/"), str_Custfilename)
                upload.SaveAs(theFilename)
                ' the file name is theFileName needs to be stored in the database.
                System.Threading.Thread.Sleep(8000)
            Else
                str_Custfilename = "default_news.jpg"
            End If

            Return "/uploadedimages/" + str_Custfilename

        End Function

==============================================================================

but i have an error in server side

the error message is
Access to the path 'D:\CustomerData\webspaces\webspace_00110365\wwwroot\uploadedimages\blackflag.jpg' is denied.

Line 105:                str_Custfilename = upload.FileName
Line 106:                theFilename = Path.Combine(HttpContext.Current.Server.MapPath("~/uploadedimages/"), str_Custfilename)
Line 107:                upload.SaveAs(theFilename)
Line 108:                ' the file name is theFileName needs to be stored in the database.
Line 109:                System.Threading.Thread.Sleep(8000)

pl's help me ?
Posted
Updated 16-Jan-12 2:24am
v2

 
Share this answer
 
You need to check three things:
1) Does the file exist and it is complaining for that reason.
2) Does the folder "uploadedimages" exist and is the name absolutely correct, including case? (depending on your host, folder names can be case sensitive)
3) Does the folder have write permissions to everybody, or at least to the account the app is to run under?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900