473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with HttpPostedFile

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.

Sep 12 '07 #1
1 2668
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.F ileName)

fileUpload is the name of the control.

Regards.

Sep 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Corkum | last post by:
Good morning. I am working on an issue that is just baffling me. I have developed an .aspx page that receives an http form post that has a "file" attribute. When I do testing with a test post...
4
by: | last post by:
Hi! It seems the HttpPostedFile object can't save a file to a destination withing the web's structure. I want to upload pictures from a page and store them in a subfolder to the web folder...
1
by: terrorix | last post by:
I want to save uploaded file to disk. I have this construction: HttpPostedFile myFile = ((HttpRequest)Request).Files; if (myFile != null) { string fn =...
8
by: Al Smith | last post by:
Hi, I am able to use the HttpPostedFile.SaveAs() method to upload and save a file to the local web machine. However, I would really like to save the file to a VirtualDirectory. Does anyone...
0
by: Dan Corkum | last post by:
Good morning. I am working on an issue that is just baffling me. I have developed an .aspx page that receives an http form post that has a "file" attribute. When I do testing with a test post...
4
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the...
5
by: MSDN | last post by:
Does anyone know why I am getting Invalid cast exception??? For Each oFile As System.web.HttpPostedFile In Request.Files ....... etc..... Next I Checked that
5
by: Dylan Parry | last post by:
Hi, I'm trying to upload some files via a form, and I have managed so far to save the files on the server in a temporary directory using: HttpPostedFile.SaveAs(string filename); This is a...
1
by: Ralph Watermann | last post by:
Hi, we upload an Excel-file via a FileUpload-Control into an HttpPostedFile object. Now we want to access the contained data directly without saving it to a temp file. Is this possible? So...
4
by: seedstorm | last post by:
I am using a HtmlInputFile control in ASP.NET 2.0 to upload a file in a UserControl. After upload, I am examining the HttpPostedFile property of this object to read the bytes of the uploaded file's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.