473,396 Members | 2,011 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.

Error when uploading file

I am trying to write code to allow my users to upload a file. The code I am
using is as follows:

Dim upfilename As String = ""

If fileDetails.Value <> "" AndAlso fileDetails.PostedFile.ContentLength > 0
Then

Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharAr ray())

upfilename = dir(dir.GetUpperBound(0))

fileDetails.PostedFile.SaveAs(Server.MapPath("/eventdetails/") & upfilename)

End If
When I run this code, I recieve an error similar to the following:

Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------

Could not find a part of the path "D:\Webdev_Site\eventdetails\resume.pdf".
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\Webdev_Site\eventdetails\resume.pdf".

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode) +52
System.Web.HttpPostedFile.SaveAs(String filename) +48
createevent.btnSubmit_Click(Object sender, EventArgs e) in C:\Documents
and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgte...nt.aspx.vb:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300
I have used this same code before without any problems, what do I need to do
differently?

--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 21 '05 #1
4 1079
Is the file located there?
can you copy that path and get to your resume.pdf?

if so are you using windows 2003 server, if you are make sure that pdf is
allowed to be served in IIS.

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
I am trying to write code to allow my users to upload a file. The code I am
using is as follows:

Dim upfilename As String = ""

If fileDetails.Value <> "" AndAlso fileDetails.PostedFile.ContentLength >
0 Then

Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharAr ray())

upfilename = dir(dir.GetUpperBound(0))

fileDetails.PostedFile.SaveAs(Server.MapPath("/eventdetails/") &
upfilename)

End If
When I run this code, I recieve an error similar to the following:

Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------

Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\Webdev_Site\eventdetails\resume.pdf".

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode) +52
System.Web.HttpPostedFile.SaveAs(String filename) +48
createevent.btnSubmit_Click(Object sender, EventArgs e) in C:\Documents
and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgte...nt.aspx.vb:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I have used this same code before without any problems, what do I need to
do differently?

--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 21 '05 #2
What do you mean is the file located there? I am uploading the file, not
downloading it, therefore, I do not expect it to be on the server while this
code is being executed. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Chris" <cc*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is the file located there?
can you copy that path and get to your resume.pdf?

if so are you using windows 2003 server, if you are make sure that pdf is
allowed to be served in IIS.

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
I am trying to write code to allow my users to upload a file. The code I
am using is as follows:

Dim upfilename As String = ""

If fileDetails.Value <> "" AndAlso fileDetails.PostedFile.ContentLength >
0 Then

Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharAr ray())

upfilename = dir(dir.GetUpperBound(0))

fileDetails.PostedFile.SaveAs(Server.MapPath("/eventdetails/") &
upfilename)

End If
When I run this code, I recieve an error similar to the following:

Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------

Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\Webdev_Site\eventdetails\resume.pdf".

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode) +52
System.Web.HttpPostedFile.SaveAs(String filename) +48
createevent.btnSubmit_Click(Object sender, EventArgs e) in C:\Documents
and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgte...nt.aspx.vb:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I have used this same code before without any problems, what do I need to
do differently?

--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


Nov 21 '05 #3
The error you stated is saying the file is not there. So take is as you
will.
Eather the file your trying to upload cant be found,
or the file that you uploaded did not really upload. I am unsure I would
take alook at the mappath
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP09.phx.gbl...
What do you mean is the file located there? I am uploading the file, not
downloading it, therefore, I do not expect it to be on the server while
this code is being executed. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Chris" <cc*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is the file located there?
can you copy that path and get to your resume.pdf?

if so are you using windows 2003 server, if you are make sure that pdf is
allowed to be served in IIS.

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
I am trying to write code to allow my users to upload a file. The code I
am using is as follows:

Dim upfilename As String = ""

If fileDetails.Value <> "" AndAlso fileDetails.PostedFile.ContentLength
> 0 Then

Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharAr ray())

upfilename = dir(dir.GetUpperBound(0))

fileDetails.PostedFile.SaveAs(Server.MapPath("/eventdetails/") &
upfilename)

End If
When I run this code, I recieve an error similar to the following:

Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------

Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find
a part of the path "D:\Webdev_Site\eventdetails\resume.pdf".

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode) +52
System.Web.HttpPostedFile.SaveAs(String filename) +48
createevent.btnSubmit_Click(Object sender, EventArgs e) in
C:\Documents and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgte...nt.aspx.vb:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I have used this same code before without any problems, what do I need
to do differently?

--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/



Nov 21 '05 #4
By default the ASPNET user account does not have write access to very many
folders. Most likley it does not have write access to the folder you're
specifying. Either grant it access or have ASP.NET run under a different
user account by using impersonation.

For example, you can add a line similar to this to your web.config file:
<identity impersonate="true" userName="domain\MyAppUser">
password="password"/>

For testing purposes you can have it use your user account since you know
you have the necessary permissions to write to that network location.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
I am trying to write code to allow my users to upload a file. The code I am
using is as follows:

Dim upfilename As String = ""

If fileDetails.Value <> "" AndAlso fileDetails.PostedFile.ContentLength >
0 Then

Dim dir As String() =
fileDetails.PostedFile.FileName.Split("\".ToCharAr ray())

upfilename = dir(dir.GetUpperBound(0))

fileDetails.PostedFile.SaveAs(Server.MapPath("/eventdetails/") &
upfilename)

End If
When I run this code, I recieve an error similar to the following:

Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------

Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\Webdev_Site\eventdetails\resume.pdf".

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path
"D:\Webdev_Site\eventdetails\resume.pdf".]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode) +52
System.Web.HttpPostedFile.SaveAs(String filename) +48
createevent.btnSubmit_Click(Object sender, EventArgs e) in C:\Documents
and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgte...nt.aspx.vb:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I have used this same code before without any problems, what do I need to
do differently?

--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 21 '05 #5

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

Similar topics

0
by: Marc | last post by:
Hello, I have a page where i can upload binary file (using the HTML input type=file approach). This works fine for relatively small files (<6MB)) but when files get bigger (13MB) there is a...
1
by: Nikhil | last post by:
I have a VBscript that I use to upload files onto the server. The script works fine on IIS 5.0 but on IIS 6.0 on Windows 2003 I get an error when uploading certain files. I believe its because the...
7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm"...
5
by: hb | last post by:
Hi, In my ASP.Net application 'MyWebApp' , the mode="StateServer" in <sessionState> of Web.config file, and the ASP.NET State Service is set to start automatically on the server. But every...
5
by: Nathan Sokalski | last post by:
I am trying to write code to allow my users to upload a file. The code I am using is as follows: Dim upfilename As String = "" If fileDetails.Value <> "" AndAlso...
3
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then...
1
by: wenqiang7 | last post by:
I am encountering a very strang problem with file uploading in my ASP.Net page. When we try to upload certain file, we'll get an error msg of "Cannot find server or DNS Error". We are running...
0
by: PerumalSamy | last post by:
Hi, I am getting following error while uploading my project in web. Description: An error occurred during the processing of a configuration file required to service this request. Please review...
6
by: SayamiSuchi | last post by:
hi, I have taken two file upload control (fileUpload1 and fileUpload2) and two required field validator(requiredFieldValidator1 and requiredFieldValidator2) for the two upload controls mentioned...
4
rahulephp
by: rahulephp | last post by:
i think i am missing something in the below script: It shows error an do not upload files to destination: Let me know how to solve this: <?php if (isset($_POST)) { $uploadArray=...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.