Solved

How to read the image file from file system (using URL) within aspx.cs?

Posted on 2006-06-28
5
327 Views
Last Modified: 2008-02-01
I need to process the image during the postback. The image file is stored on the website (URL path). However, when I coded the path in URL, the compiler complains. However, I really cannot specify the absolute file path in the file system. You just don't klnow where is the file (web farming).
How do I resolve this delima?
0
Comment
Question by:chuang4630
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17004665
what error are you getting?
0
 
LVL 1

Author Comment

by:chuang4630
ID: 17004729
URI formats are not supported

code:
string WorkingDirectory = "http://localhost/MySite/images/site";
System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(WorkingDirectory + "/DefaultBkg.jpg");

0
 
LVL 35

Expert Comment

by:YZlat
ID: 17004888
try

C:\Inetpub\wwwroot\MySite\images\site

instead of

http://localhost/MySite/images/site
0
 
LVL 1

Author Comment

by:chuang4630
ID: 17004933
I know you can always use the file system path. But in the production environment, how do you know the absolute file system path?
0
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 500 total points
ID: 17005328
       // url http:/mysite.com/images/page.aspx?image=pic.jpg
       string image =  Request.QueryString["image"];
       string path = Server.MapPath(" ~/images/" + image);

       System.Drawing.Image im = System.Drawing.Image.FromFile(path);
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create an MVC5, Razor Widget 2 36
insert value of checklistbox checked 4 38
ASP.NET (VB) return a record 2 51
Easy filter aspnet 2 34
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question