Problem with HttpPostedFile

  • Thread starter Thread starter mcarrera00
  • Start date Start date
M

mcarrera00

Hi,

I have a problem with uploading files to a webserver.
Here it's the code

Dim strPath As String = MapPath(fileName).ToLower

strPath = strPath.Replace("\usercntrls", "\uploads")

fileUpload.PostedFile.SaveAs(strPath)

usercntrls is where the control resides on the server, upload is the
destination where the file is supposed to be saved. When the problem
occurs, the file gets saved in usercntrls, rather than in uploads.
What drives me nut is that sometimes the file is saved in the proper
location, sometimes not. It should not be a problem of permissions,
and if the file exists, it should be overwritten. Sometimes it get
fixed recompiling the application and uploading the dlls...

Any idea?

Thanks a lot!

Marco.
 
Dim strPath As String = MapPath(fileName).ToLower

strPath = strPath.Replace("\usercntrls", "\uploads")

fileUpload.PostedFile.SaveAs(strPath)

I forgot to mention, before this code:

Dim fileName As String =
System.IO.Path.GetFileName(fileUpload.PostedFile.FileName)

fileUpload is the name of the control.

Regards.
 
Back
Top