Last post Aug 19, 2011 09:08 AM by Pavel_147
Aug 19, 2011 04:31 AM|Pavel_147|LINK
Is there some possibility to upload image using System.Web.UI.WebControls.Image object.
The poriblem consists in specifying of the ImageUrl property.
When image is stored in some website directory it's Ok.
But how to proceed when image directory is somewhere in file system.
I trying something like this:
ImageUrl = file:///C:/Direct_1/Subdir_1/Subdir_2/ImageFile.jpg, but it doesn't work.
Thanks in advance.
Aug 19, 2011 04:37 AM|MayankArora|LINK
You have write the url in this case not physical path.
if this directory is present in you web application /website the it shouls be like this.
InageUrl = "~/foldername/ImageFile.jpg"
let me know if any query.
Aug 19, 2011 04:59 AM|Pavel_147|LINK
Mayank, thank you for response.
This option is rather difficult to implement, because the image store directory should have a possibility to be changed.
Aug 19, 2011 09:08 AM|Pavel_147|LINK
It seems I found workaround.
For this particular task one should use graphics obects from System.Drawing.
1. Create object Bitmap, where image size is defined.
Bitmap image = new
2. Create object Graphics and associate it with object
Graphics g = Graphics.FromImage(image);
3. Create object Image and upload image file in it.
System.Drawing.Image file_img = System.Drawing.Image.FromFile(full_file_name);
4. Draw object Image using object Graphics.
g.DrawImageUnscaled(file_img, 0, 0);
5. Output object Bitmap onto web page.
6. Release resourses.