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
Solved

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

Posted on 2006-06-28
5
320 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

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…
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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