Problem with HttpPostedFile

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.
 
M

mcarrera00

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top