Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 10th, 2006, 12:16 PM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default Error posting photo to photo album

Hi,

Got my photo album all setup and configured. I logged in, created a test photo album, and found an image to upload to test the app.

I saved the app to my desktop, it is a .jpeg image file, and when I tried to upload the photo to album "Test", I received the following error. My first thought was maybe there's a problem with the path, since the path to the desktop in many apps is that of one which is surrounded by quotation marks due to the spaces in the path.

However, being a newbie to appDev, I really have no idea, but thought I would submit this in case this is something not yet discovered, and may be a bug in the app.

I will test a few more things and post my findings to this post in reply. In the meantime, if anyone has run into this (or something similar), could you post what you did that made it work?

Thanks in advance. Details on the error are as follows:



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

Could not find a part of the path 'C:\inetpub\wwwroot\PhotoGallery\upload\littleGirl .jpg'.
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 'C:\inetpub\wwwroot\PhotoGallery\upload\littleGirl .jpg'.

Source Error:


Line 16: if FileUpload1.FileName <> "" then
Line 17:
Line 18: FileUpload1.SaveAs("C:\\inetpub\\wwwroot\\PhotoGal lery\\upload\\" + FileUpload1.FileName)
Line 19:
Line 20: Dim p As New Photo(ddcollections.SelectedValue, txtName.Text, FileUpload1.FileName, txtDesc.Text)


Source File: D:\inetpub\wwwroot\photoalbum\secure\addphoto.aspx Line: 18

Stack Trace:


[DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\PhotoGallery\upload\littleGirl .jpg'.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014672
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +998
   System.IO.FileStream..ctor(String path, FileMode mode) +65
   System.Web.HttpPostedFile.SaveAs(String filename) +84
   System.Web.UI.WebControls.FileUpload.SaveAs(String filename) +23
   ASP.secure_addphoto_aspx.Upload(Object sender, EventArgs e) in D:\inetpub\wwwroot\photoalbum\secure\addphoto.aspx :18
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4917




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

  #2 (permalink)  
Old August 10th, 2006, 12:25 PM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default

Nope, I copied this .jpeg file to my root of C:\, and got the same error. In case the error is a bit different, I am posting the entire error, yet again:

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

Could not find a part of the path 'C:\inetpub\wwwroot\PhotoGallery\upload\littleGirl .jpg'.
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 'C:\inetpub\wwwroot\PhotoGallery\upload\littleGirl .jpg'.

Source Error:


Line 16: if FileUpload1.FileName <> "" then
Line 17:
Line 18: FileUpload1.SaveAs("C:\\inetpub\\wwwroot\\PhotoGal lery\\upload\\" + FileUpload1.FileName)
Line 19:
Line 20: Dim p As New Photo(ddcollections.SelectedValue, txtName.Text, FileUpload1.FileName, txtDesc.Text)


Source File: D:\inetpub\wwwroot\photoalbum\secure\addphoto.aspx Line: 18

Stack Trace:


[DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\PhotoGallery\upload\littleGirl .jpg'.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014672
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +998
   System.IO.FileStream..ctor(String path, FileMode mode) +65
   System.Web.HttpPostedFile.SaveAs(String filename) +84
   System.Web.UI.WebControls.FileUpload.SaveAs(String filename) +23
   ASP.secure_addphoto_aspx.Upload(Object sender, EventArgs e) in D:\inetpub\wwwroot\photoalbum\secure\addphoto.aspx :18
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4917




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

  #3 (permalink)  
Old August 10th, 2006, 03:12 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

Take a look at this:
Quote:
quote:FileUpload1.SaveAs("C:\\inetpub\\wwwroot\\Ph otoGallery\\upload\\" + FileUpload1.FileName)
and this
Quote:
quote:Source File: D:\inetpub\wwwroot\photoalbum\secure\addphoto.aspx Line: 18
The book assumes that the application is stored under c:\inetpub. Apparently, you installed at the D drive which is fine as well, but requires a change in the code.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #4 (permalink)  
Old August 11th, 2006, 07:49 PM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default

Actually, it looks like the drive has nothing to do with it; at least not from that perspective.

I have it installed in the default location under c:\inetpub\wwwroot\photoalbum, and I still get the same error, as I just now tried.

I have this directory setup like all of the others that work, and have copied the updated files into the photoalbum dir, so everything's updated as well.

I'll keep looking, but I wanted to let you know that this was not the problem, or at least not from the response of it being in a directory other than c:\inetpub\wwwroot\photoalbum, as it is now in that directory, as are all of my other apps.

Here's the code of the error:


=========BEGIN CODE==================

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

Could not find a part of the path 'C:\inetpub\wwwroot\PhotoGallery\upload\e_j_22jul0 6.JPG'.
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 'C:\inetpub\wwwroot\PhotoGallery\upload\e_j_22jul0 6.JPG'.

Source Error:


Line 16: if FileUpload1.FileName <> "" then
Line 17:
Line 18: FileUpload1.SaveAs("C:\\inetpub\\wwwroot\\PhotoGal lery\\upload\\" + FileUpload1.FileName)
Line 19:
Line 20: Dim p As New Photo(ddcollections.SelectedValue, txtName.Text, FileUpload1.FileName, txtDesc.Text)


Source File: C:\Inetpub\wwwroot\photoalbum\secure\addphoto.aspx Line: 18

Stack Trace:


[DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\PhotoGallery\upload\e_j_22jul0 6.JPG'.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014672
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +998
   System.IO.FileStream..ctor(String path, FileMode mode) +65
   System.Web.HttpPostedFile.SaveAs(String filename) +84
   System.Web.UI.WebControls.FileUpload.SaveAs(String filename) +23
   ASP.secure_addphoto_aspx.Upload(Object sender, EventArgs e) in C:\Inetpub\wwwroot\photoalbum\secure\addphoto.aspx :18
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42



=============END CODE===============

Thanks

  #5 (permalink)  
Old August 11th, 2006, 07:52 PM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default

Or, do you mean that I need to put the photos in that directory?

And, if that's the case, this app is setup under all photos being in a particular directory, that being c:\inetpub\wwwroot\photoalbum?

That's not a problem if that's the case, but I do need to ask (again, assuming that my question above is a YES), is there a way to circumvent the limitation of the photos having to be in a specific directory so that the source dir is irrelevant when uploading photos?

I'm sure there's documentation on the web about this, and I'll eventually find some, but I wanted to stay as close to the source as I can so as to not invite more troubleshooting than is already existing. These errors can branch out into black holes, as I've found, so the more simpler I can keep it, the saner I am. :)

  #6 (permalink)  
Old August 11th, 2006, 08:18 PM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default

Ok, I figured out what the problem is. Actually, there are two problems, 1 main problem, and a sub-problem below that.

Here's what I found:
1. when uploading, the program is looking to dump the photo in:
"c:\inetpub\wwwroot\photogallery\upload"
However, there's no directory there, and the program does not create it. Maybe the installer.exe file does, but manually, this doesn't happen, and this isn't stated in the manual installation process in the book, so I will submit a form for the errata update.

1a. Once I uploaded the photo, the title and a little background image of something showed up, but the photo itself doesn't show up, just some mini image of a sort, so I will look through the book, and fill out another update for the errata if it's not posted there.

This is fun! At least I got to contribute here this time instead of always posting my troubleshooting issues. :)

  #7 (permalink)  
Old August 12th, 2006, 02:04 AM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default

Looks like I was wrong. Well, from another issue that's related to this one.

The photos show that they are being uploaded to the directory, but they don't actually make it, and what is there is some sort of mini image in its place. I checked the directory, and it appears to have all of the correct permissions set on it. I copied the photos to the directory, and they show up in the web page, but going through the application, the photos don't actually get uploaded.

Back to the drawing board, I guess.

  #8 (permalink)  
Old August 12th, 2006, 08:40 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

Here's what's happening.

The application assumes it's installed in C:\inetpub\wwwroot\PhotoGallery. So, the code tries to save uploaded pictures in C:\inetpub\wwwroot\PhotoGallery\upload.

To make the app independent from its physical location you can modify the code that saves the picture.

Try this:

1. Open addphoto.aspx from the secure folder

2. Scroll down to around ine 18 and locate the line that saves the picture.

3. Replace that line with this code:

FileUpload1.SaveAs(System.IO.Path.Combine(Server.M apPath("~/upload"), FileUpload1.FileName))

4. Save and run

The Server.MapPath instruction maps a virtual path to a physical location. So, when your app is located at

C:\inetpub\wwwroot\PhotoAlbum,

pictures are saved at

C:\inetpub\wwwroot\PhotoAlbum\upload

But when your app lives at

D:\inetpub\wwwroot\PhotoGallery

the pictures are saved at

D:\inetpub\wwwroot\PhotoGallery\upload

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #9 (permalink)  
Old August 12th, 2006, 10:35 AM
Authorized User
 
Join Date: Aug 2006
Location: Anaheim, CA, USA.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to abel714 Send a message via Yahoo to abel714
Default

Quote:
quote:Originally posted by Imar
 Here's what's happening.

The application assumes it's installed in C:\inetpub\wwwroot\PhotoGallery. So, the code tries to save uploaded pictures in C:\inetpub\wwwroot\PhotoGallery\upload.

To make the app independent from its physical location you can modify the code that saves the picture.

Try this:

1. Open addphoto.aspx from the secure folder

2. Scroll down to around ine 18 and locate the line that saves the picture.

3. Replace that line with this code:

FileUpload1.SaveAs(System.IO.Path.Combine(Server.M apPath("~/upload"), FileUpload1.FileName))

4. Save and run

The Server.MapPath instruction maps a virtual path to a physical location. So, when your app is located at

C:\inetpub\wwwroot\PhotoAlbum,

pictures are saved at

C:\inetpub\wwwroot\PhotoAlbum\upload

But when your app lives at

D:\inetpub\wwwroot\PhotoGallery

the pictures are saved at

D:\inetpub\wwwroot\PhotoGallery\upload

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
That did it. Thanks a bunch.

Is there a site or reference that you'd recommend where I can go to figure out how to manipulate this?

I'd like to store the photos in different directories, and since I'm not too familiar with this code, and I'm not sure if it is elaborated upon in the book, I thought I'd ask.

Thanks again for the quick response, and helping me figure these out.

  #10 (permalink)  
Old August 12th, 2006, 10:47 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

Quote:
quote:Is there a site or reference that you'd recommend where I can go to figure out how to manipulate this?
Can you elaborate a bit about this? What do you want to manipulate?

You may want to take a look at the System.IO namespace. It contains a number of useful classes, like File and Directory that allow you to work with files and folders; like create folders, copy and move files and so on.

Is this what you meant?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
paging in photo album xperre BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 April 2nd, 2007 03:32 PM
Photo Album - interesting error abel714 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 8 January 4th, 2007 05:29 PM
Wrox Photo Album Help rsearing BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 6 September 27th, 2006 02:30 PM
Photo Album Menus Tremmorkeep BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 August 15th, 2006 01:49 PM



All times are GMT -4. The time now is 01:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.