473,395 Members | 1,756 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,395 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 19 '05 #1
5 4666
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 19 '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 19 '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 19 '05 #4
Perhaps the eventdetails folder does not exist or the app doesn't have access
to it....

"Nathan Sokalski" wrote:
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 19 '05 #5
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 19 '05 #6

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...
4
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.