Solved

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

Posted on 2006-06-28
5
335 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need syntax help building hyperlink 2 51
YouTube API get the Video Tags - vb.net 7 48
EF5 How do I stop pre-compiled views? 8 48
How do I "share" on social sites? 2 33
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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