newbie: image problems again

J

Jeff

hey

asp.net 2.0

my problem is that on a webpage am I trying to dynamically display the image
a user has uploaded. But the webpage doesn't display the image. The browser
displays the standard image telling that image not found / broken image link
etc....

This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName +
".jpeg"));

This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg");

The image exist in that folder

Any suggestions to this error?

Jeff
 
M

Matthias Pieroth

Hi Jeff,

does this variable "Profile.UserName" really exist when you try to load the
image. Did you place an exception-handler around the loading-method?

Bye,
 
J

Jeff

Hey

it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");

I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success....

any suggestions?

Jeff
 
V

V

Hi Jeff,

I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.

2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\.....

I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.

- V
 
J

Jeff

The path is
C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\BN\Images\Fullsize\test.jpeg

I've checked and path is correct, but the path contains spaces....

I'm not sure about it but maybe the browser need to know if this is a
picture ("image/thumb")???




Jeff
 
V

V

It is possible that you may need to grant permission to the asp.net
process on that image directory. It might be a problem with the
security.

- V
 
J

Jeff

I replaced this line:

imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");

with this line

imgPicture.ImageUrl = "~/Images/Fullsize/test.jpeg";

And now it works

Thank you very much for helping me with this. The best thing with this
problem is that I've learned from it -> maybe using Server.MapPath isn't
best all the times....

Best Regards!

Jeff
 

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

Similar Threads


Top