Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2005, 03:06 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems loading images via FSO

Hi,
I have an employee directory in an Access Db. Typical columns include First_Name, Last_Name,...

I've created a dynamic table which lists all the employees... so far so good.
My problem is when I try and retreive a picture of an employee using FSO.

Here the meat of my code calling the jpg:

************************************************** *****************
<%
Set fso = CreateObject("Scripting.FileSystemObject")
Dim PICurl

PICurl="/DB/EmployeePics/" & replace(rsDirectory("First_Name"),"-",("Last_Name")) & ".jpg"


strpath=Server.MapPath(PICurl)%>
      <td align="center" nowrap>
     <%If (fso.FileExists(strpath)) Then%> <a href="<%=PICurl%>" target="_blank" class="docs"><img src="../img/EMPpic.jpg"></a>
         <% Else
        response.write("<P class=""docs"">no pic</P>")
    End If
    %>
************************************************** *****************

My path works fine. I think its in the way (syntax) I call each jpg.
You see, here's my file naming convention for those pics:

Firstname-Lastname.jpg

ie: john-smith.jpg

Please help,

Thanks,
 nancy


 
Old April 21st, 2005, 03:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And what's the problem you're experiencing?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 21st, 2005, 03:52 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar, you've alays been very good at responding to my requests in a very speedy fashion. I appreciate it.

To be frank, I have set the images with the filenaming convention mentioned earlier, but all I get as results is "no pic", in that column instead of having the "Hot" image to click on in order view that picture.

What could it be?

 
Old April 21st, 2005, 04:11 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Try this:

strpath = Server.MapPath(PICurl)

Response.Write("Physical filename is " & strpath & "<br />")
Response.Write("Virtual filename is " & PICurl& "<br />")
%>

What does it say? Does the first location represent an existing file?

And what happens when you add http://YourServer in front of the second Response.Write output and paste that in a browser? Can you browse to the image?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 22nd, 2005, 08:17 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,
 I never thought of troubleshooting this way... thanks for the tip!

Here's the results:

Physical filename is E:\Inetpub\INTRANET\DB\EmployeePics\Allan.jpg
Virtual filename is /DB/EmployeePics/Allan.jpg

Briefly both are correct (I think). I think the error resides in "reading" the First_Name of the filenaming convention, not the full name separated by a hyphen as stipulated in previous thread.

We're almost there!
Imar could you look into my syntax above It is always confusing for me to do "ASP- replace..."

Thanks again,
nancy
 
Old April 22nd, 2005, 10:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right, I see now what you mean with Replace.

Why are you using that in the first place? (no pun intended)

Try this instead:

PICurl="/DB/EmployeePics/" & rsDirectory("First_Name") & "-" & ("Last_Name") & ".jpg"

This contatenaes the first name, a hyphen,,the last name and .jpg so you end up with

john-smith.jpg

which is what you're after, I think.

What was the idea behind using Replace?

Imar





Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Background images not loading in ASP.NET 2.0 vinyel23 ASP.NET 2.0 Basics 0 January 5th, 2007 12:54 PM
Loading Images ShaileshShinde General .NET 0 October 5th, 2005 01:50 AM
Problems in Loading Image ctranjith General .NET 0 December 18th, 2004 06:01 AM
FSO Checking if images exist harpua Classic ASP Basics 5 September 1st, 2004 09:02 PM
Loading Images & Interact with Outlook wasaan SQL Server ASP 1 August 4th, 2003 06:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.