Solved

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

Posted on 2006-06-28
5
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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