Images Not Displaying

M

Mark Sargent

Hi All,

response.write FilePath gives this path, ImageName.jpeg but the image(s)
doesn't display in the below code. What am I missing..? Cheers.

<%Response.Write FilePath%>
Original Image:<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\") & FilePath%>"><P>

Thumbnail (50% reduction):<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\Thumbs\Thumb") & FilePath%>">

The files definitely exist in the database.

Mark Sargent.
 
S

Stuart Palmer

View source of the page generated and see what the output is coming out as.
It may be you are missing the \ before imageuploads, but without the source
it's difficult to say. Depends also the value of Filepath as well.

Stu
 
S

Steven Burn

I recently had this problem when converting part of my site and found the
cause to be in the Server.MapPath code

I had it as ./ (which it was previously as the main pages for them were in
the same folder as the images) and as I had the new pages in a sub-folder of
the root, I had to change it to ../path/sub-folder instead. I could be wrong
but, it would seem that Server.MapPath is unable to interpret sub-folder
paths normally used in image tags etc. (atleast, because of the problem I
experienced and the only way I found to solve it..... gives me that
impression).

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part :eek:)
 
M

Mark Sargent

Hi All,

k, the images are found via this path,
rootfolder\Classifieds\ImageUploads\ImageName.jpeg..FilePath =
ImageName.jpeg without a preceeding \. Would only need a preceeding ../ if
the start folder was one folder above....still stumped. Cheers.

Mark Sargent.
 
M

Mark Sargent

full code below...cheers...

<HTML>
<HEAD>
<TITLE>AspJpeg - Simple.asp</TITLE>
</HEAD>
<BODY>
<%
Dim FilePath
if Request.QueryString("FilePath") <> "" then
FilePath = Request.QueryString("FilePath")
End If
Response.Write FilePath
%>
<%
' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Compute path to source image
Path = Server.MapPath(FilePath)

' Open source image
Jpeg.Open Path

' Decrease image size by %
Jpeg.Width = Jpeg.OriginalWidth / 1.1
Jpeg.Height = Jpeg.OriginalHeight / 1.1

' Apply sharpening if necessary
' Jpeg.Sharpen 1, 130

' create thumbnail and save it to disk
FilePath = Replace(FilePath, "/", "\")
FilePath = Replace(FilePath, "ImageUploads\", "")
Jpeg.Save Server.MapPath("ImageUploads\Thumbs") & "\Thumb" & FilePath


%>
<%Response.Write FilePath%>
Original Image:<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\") & FilePath%>"><P>

Thumbnail (% reduction):<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\Thumbs\Thumb") & FilePath%>"><P>
</BODY>
</HTML>


The created thumbnail is being saved to the harddrive no problems...cheers..

Mark Sargent.
 
S

Steven Burn

Just a guess here but, you've said FilePath = the filename?. Are you adding
a \ between the path and the filename?

e.g. Server.MapPath("ImageUploads\Thumbs\Thumb") & "\" & FilePath

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part :eek:)
 
M

Mark Sargent

why would I need that..? FilePath = the path minus ImageUploads/ which you
would see in the full code post. Here is how it's done, step by step...the
path passed to the page is, ImageUpoads/FileName.jpeg. I then replace / with
\ to pull the image from the drive. I then remove the path, ImageUploads\
which just leaves the image name and then save as a Thumbnail. I then want
to show the original and the created/saved Thumbnail before continuing to
delete the un-needed original and subsequently addng the Thumbnail path into
the Database. Hope that makes sense. Perhaps someone will have a quicker,
more efficient way of doing all this, just this is the best I could imagine
so far. Cheers.

Mark Sargent.
 
M

Mark Sargent

Hi All,

K, perhaps I didn't explain myself well enuff. The original file is being
resized and the thumb is being created and saved to the drive. The below
code doesn't seem to write the image to the browser, though. FilePath = just
the file name(original), example, MyPic.jpeg, which would be found here,
ImageUploads\MyPic.jpeg, on the drive. Why is this not working..? Cheers.

Mark Sargent.


<%Response.Write FilePath & "<br>"%>
Original Image:<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\") & FilePath%>"><P>

Thumbnail (% reduction):<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\Thumbs\Thumb") & FilePath%>">

Below is the code used to save the thumb,

FilePath = Replace(FilePath, "ImageUploads/", "")
Jpeg.Save Server.MapPath("ImageUploads\Thumbs") & "\Thumb" & FilePath
 
M

Mark Sargent

now, now, young Raymond, no need to get snippet...lol...k,
understood..cheers.

Mark Sargent.
 
M

Mark Sargent

<html>
<head>
<title>easyboarder - Image Resize</title>
</head>
<body>
<div align="center">
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>ImageUploads/JPSnakeJBayPro(28).jpg<br>JPSnakeJBayPro(28).jpg<br>
Original Image:<br>
<img SRC="C:\Documents and Settings\wombat\My
Documents\easyboarder\wwwroot\Classifieds\ImageUploadsJPSnakeJBayPro(28).jpg
"></p></div>
<p align="center"> Thumbnail (% reduction):<br>
<img SRC="C:\Documents and Settings\wombat\My
Documents\easyboarder\wwwroot\Classifieds\ImageUploads\Thumbs\ThumbJPSnakeJB
ayPro(28).jpg">
<p align="center">
</body>
</html>
 
S

Steven Burn

aah, I can hear Loraina already ;o)

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
S

Steven Burn

"C:\Documents and Settings\wombat\My
Documents\easyboarder\wwwroot\Classifieds\ImageUploadsJPSnakeJBayPro(28).jpg
"

Look at the end of the path.

\ImageUploadsJPSnakeJBayPro(28).jpg

there's no \ between ImageUploads and the filename

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
S

Steven Burn

Try;

FilePath = "\" & filename (where filename is whatever your using for the
filenames)

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
M

Mark Sargent

This code below,

<%Response.Write FilePath & "<br>"
ImagePath = Server.MapPath("ImageUploads") & "/" & FilePath
ImagePath = Replace(ImagePath, "\", "/")
Response.Write ImagePath & "<br>"%>
Original Image:<BR>

<IMG SRC="<%=ImagePath %>"></p></div>
<P align="center"> Thumbnail (% reduction):<BR>
<IMG SRC="<%=Server.MapPath("ImageUploads\Thumbs\Thumb") & FilePath%>">
<P align="center">

gives the source below,
<html>
<head>
<title>easyboarder - Image Resize</title>
</head>
<body>
<div align="center">
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>$B!!(B</p>
<p>$B!!(B</p>

<p>ImageUploads/JPSnakeJBayPro(28).jpg<br>JPSnakeJBayPro(28).jpg<br>C:/Docum
ents and Settings/wombat/My
Documents/easyboarder/wwwroot/Classifieds/ImageUploads/JPSnakeJBayPro(28).jp
g<br>
Original Image:<br>

<img SRC="C:/Documents and Settings/wombat/My
Documents/easyboarder/wwwroot/Classifieds/ImageUploads/JPSnakeJBayPro(28).jp
g"></p></div>
<p align="center"> Thumbnail (% reduction):<br>
<img SRC="C:\Documents and Settings\wombat\My
Documents\easyboarder\wwwroot\Classifieds\ImageUploads\Thumbs\ThumbJPSnakeJB
ayPro(28).jpg">
<p align="center">
</body>
</html>
cheersMark Sargent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top