Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

FileSystemObject ?

LEGEND ,
Jul 08, 2008 Jul 08, 2008
Below is a sample of what I am doing. It checks if an image exists and
on the server. If the product image doesn't exist, it looks for group
image. If that one doesn't exist, it should display a "no image"
message. That's it in a nutshell.

I was wondering if there's anything glaringly wrong...Thanks.

<%Set fs=Server.CreateObject("Scripting.FileSystemObject")%>
<% strFile1 = "f:\path\to\images\science\DD" &
(rsRecordset.Fields.Item("ProductID").Value) & ".jpg" %>
<% strFile2 = "f:\path\to\images\science\DD" &
(rsRecordset.Fields.Item("gid").Value) & ".jpg"%>
<%If ((fs.FileExists(strFile1))=true) Then%>.
<img
src=" http://www.domain.com/prodPix/science/DD<%=(rsRecordset.Fields.Item("ProductTable").Value)%>.jpg"
alt="<%=(rsRecordset.Fields.Item("Name").Value)%>"/>
<% If ((fs.FileExists(strFile1))<>true AND
((fs.FileExists(strFile2))=true)) Then %>
..<img
src=" http://www.domain.com/prodPix/science/DD<%=(rsRecordset.Fields.Item("GroupID").Value)%>.jpg"
alt="<%=(rsRecordset.Fields.Item("Name").Value)%>"/><br />
<span class="style2">Photo is of Parent Grouping</span>
<% If ((fs.FileExists(strFile1))<>true)
AND((fs.FileExists(strFile2))<>true) Then %>
<div class="rightcontent">No Image Available </div>
<%end if 'strFile1 %>
<%end if 'strFile2 %>
<%end if 'both false %>
<br />
TOPICS
Server side applications
425
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2008 Jul 08, 2008
I probably found the solution to this. It turns out my host put my sites
on different servers...:( Consequently, the script couldn't find the file.

> Below is a sample of what I am doing. It checks if an image exists and
> on the server. If the product image doesn't exist, it looks for group
> image. If that one doesn't exist, it should display a "no image"
> message. That's it in a nutshell.
>
> I was wondering if there's anything glaringly wrong...Thanks.
>
> <%Set fs=Server.CreateObject("Scripting.FileSystemObject")%>
> <% strFile1 = "f:\path\to\images\science\DD" &
> (rsRecordset.Fields.Item("ProductID").Value) & ".jpg" %>
> <% strFile2 = "f:\path\to\images\science\DD" &
> (rsRecordset.Fields.Item("gid").Value) & ".jpg"%>
> <%If ((fs.FileExists(strFile1))=true) Then%>.
> <img
> src=" http://www.domain.com/prodPix/science/DD<%=(rsRecordset.Fields.Item("ProductTable").Value)%>.jpg"
> alt="<%=(rsRecordset.Fields.Item("Name").Value)%>"/>
> <% If ((fs.FileExists(strFile1))<>true AND
> ((fs.FileExists(strFile2))=true)) Then %>
> ..<img
> src=" http://www.domain.com/prodPix/science/DD<%=(rsRecordset.Fields.Item("GroupID").Value)%>.jpg"
> alt="<%=(rsRecordset.Fields.Item("Name").Value)%>"/><br />
> <span class="style2">Photo is of Parent Grouping</span>
> <% If ((fs.FileExists(strFile1))<>true)
> AND((fs.FileExists(strFile2))<>true) Then %>
> <div class="rightcontent">No Image Available </div>
> <%end if 'strFile1 %>
> <%end if 'strFile2 %>
> <%end if 'both false %>
> <br />
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2008 Jul 08, 2008
Art wrote:
> I probably found the solution to this. It turns out my host put my sites
> on different servers...:( Consequently, the script couldn't find the file.

I use:
<% If fso.FileExists (server.mappath("/images/..........

That way I don't concern myself with the physical path, the server does
it for me, as it knows what the path is already.

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2008 Jul 08, 2008
Dooza wrote:
> Art wrote:
>> I probably found the solution to this. It turns out my host put my
>> sites on different servers...:( Consequently, the script couldn't find
>> the file.
>
> I use:
> <% If fso.FileExists (server.mappath("/images/..........
>
> That way I don't concern myself with the physical path, the server does
> it for me, as it knows what the path is already.
>
> Steve
Thanks Steve,
That looks like it would work for my main site. My problem is that I'm
using it across 3 domain names and the problem I just discovered is that
the two domains that use this are on different servers completely.

I'm in the process of fixing this but I think when I am done, I'll need
to use the direct path for these other two domains once they get moved
to the same location.

Thanks for the suggestion.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2008 Jul 08, 2008
Art wrote:
> Dooza wrote:
>> Art wrote:
>>> I probably found the solution to this. It turns out my host put my
>>> sites on different servers...:( Consequently, the script couldn't
>>> find the file.
>>
>> I use:
>> <% If fso.FileExists (server.mappath("/images/..........
>>
>> That way I don't concern myself with the physical path, the server
>> does it for me, as it knows what the path is already.
>>
>> Steve
> Thanks Steve,
> That looks like it would work for my main site. My problem is that I'm
> using it across 3 domain names and the problem I just discovered is that
> the two domains that use this are on different servers completely.
>
> I'm in the process of fixing this but I think when I am done, I'll need
> to use the direct path for these other two domains once they get moved
> to the same location.
>
> Thanks for the suggestion.

It should work for all your servers, doesn't matter what the path to
your web files are, this will put the correct one in no matter which
server your on, give it ago and see.

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2008 Jul 08, 2008
So what does your whole script block look like?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2008 Jul 08, 2008
Art wrote:
> So what does your whole script block look like?
I'm having a hard time visualizing how I should plug that into my own
example .
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2008 Jul 09, 2008
Art wrote:
> Art wrote:
>> So what does your whole script block look like?
> I'm having a hard time visualizing how I should plug that into my own
> example .

This is what your code looks like:

<% strFile1 = "f:\path\to\images\science\DD" &
(rsRecordset.Fields.Item("ProductID").Value) & ".jpg" %>

It should look like this:

<% strFile1 = Server.MapPath("\images\science\DD" &
(rsRecordset.Fields.Item("ProductID").Value) & ".jpg") %>

http://www.w3schools.com/ASP/met_mappath.asp

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2008 Jul 09, 2008
LATEST
Art wrote:
> So what does your whole script block look like?

<% Set fso = createobject("scripting.filesystemobject") %>

<% If fso.FileExists (server.mappath("/images/products/thumbs/" &
(rsProducts.Fields.Item("itm_wpicture").Value))) then %>
<a
href="/shop/view.asp?ID=<%=(rsProducts.Fields.Item("itm_item").Value)%>"><img
src="/images/products/thumbs/<%=(rsProducts.Fields.Item("itm_wpicture").Value)%>"
alt="<%=(rsProducts.Fields.Item("itm_item").Value)%>" width="100"
height="100" border="0"
title="<%=(rsProducts.Fields.Item("itm_item").Value)%>" /></a>
<% Else %>
<img src="/images/manufacturer/thumbs/nologo.jpg" alt="" width="100"
height="100" border="0" /></a>
<%End if%>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines