Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 12, 2012 07:27 AM by sudha4999
Jul 11, 2011 03:02 PM|LINK
I'm manipulating an image on the fly on my web page.
WebClient wc = new WebClient();
string path = Server.MapPath(@"~/Some/path/image.png");
System.Drawing.Image bmp = System.Drawing.Image.FromFile(path,true);
Graphics g = Graphics.FromImage(bmp);
So I do my manipulation on G, Once I have drawn what I want to draw on my image, I save it to a file, then load that file into my image control.
MemoryStream tempStream = new MemoryStream();
FileStream outStream = File.OpenWrite(Server.MapPath(@"~/Some/path/image_temp.png")); tempStream.WriteTo(outStream);
outStream.Flush(); outStream.Close(); imgAbsRiskBar.ImageUrl = Server.MapPath(@"~/Some/path/image_temp.png");
Unfortunately, even thought the imageurl of the image control has nothing set, and it is being set to this temporary image path it doesn't display on my page. The visibility of the control is set to true. I'm at a loss as it doens't error out, it doesn't
spit it's dummy it just won't display the image.
Any help would be greatly appreciated.
Jul 11, 2011 07:25 PM|LINK
Server.Mappath() maps to the local filesystem path. You appear to be assigning that path to the ImageUrl property, rather than the url.
Jul 12, 2011 08:08 AM|LINK
I want to store the images on the server, I don't want them stored on the client. That's why I'm using Server.MapPath(). Asp:Image doesn't have a "Url" property.
Jul 12, 2011 12:04 PM|LINK
Your image is already stored The ImageUrl property needs an url, not a local path. That's why it's
ImageUrl rather than
Jul 12, 2011 01:07 PM|LINK
When I remove the Server.MapPath() and just pass in "~/images/image.png" I get a FileNotFoundException when I get Image From File.
Probably making a beginners mistake.
*edit* Ok, fixed it, you need the server.map path everywhere you are referring to the "FILE" if you want to assign the stored image to the image control, then you have to pass in a url.
Thanks very much, learn something new everyday.
Oct 12, 2012 07:27 AM|LINK
I am facing the same issue ... can anyone explain me what should i do to load that image to my imgurl??