Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

problem reading a pdf in ASP

  • 16-10-2008 02:33PM
    #1
    Registered Users, Registered Users 2 Posts: 224 ✭✭


    Hello All,

    I have been thrown a curve ball. Basically I have a bit of code that looks you a field and if its null or empty it displays a “no image available” image otherwise it shows the jpg. That works sweet.

    Now here is the curve ball. If the attachment is a pdf it will show a missing image with red x. is there anyway I can read the extension and just display in this case a pdf extension image or the actual jpg or gif image if its a jpg or gif
    This is what im currently using.

    ***********************************************

    <%

    Dim strQImage8

    Dim vQuotebtn8

    vQuotebtn8=false

    If rsNewArtApp.Fields("image4").Value <> "" or isnull(rsNewArtApp.Fields("image4").Value) Then

    vQuotebtn8=true

    End If

    If vQuotebtn8=false then

    strQImage8="../siteimgs1/noimage.jpg"

    Else

    strQImage8="../artappimgs/"&(rsNewArtApp.Fields.Item("Image4").Value)

    End If

    %>

    <td><div align="center"><A HREF="<%=strQImage8%>" target="_blank"><img src="<%=strQImage8%>" width="100" border="0" class="imageborder" target="_blank"></A></div></td>



    ************************************************** **


Comments

  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Absolutely - strQImage8 is the filename right? So, just check the last three characters of it and see if it's pdf.
    If vQuotebtn8=false then
        strQImage8="../siteimgs1/noimage.jpg"
    Else
        If right(Lcase(strQImage8), 3) = "pdf" Then
            strQImage8="../siteimgs1/pdf.jpg"
        Else
            strQImage8="../artappimgs/"&(rsNewArtApp.Fields.Item("Image4").Value)
        End If
    End If
    


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Hi eoin,

    Thats still not working. Still bringing up the missing image x. I have changed it to bring up the "noimage.jpg" which works elsewhere on the page but to no avail.

    Here is the complete code with your bit added in.

    *************

    <%
    Dim strQImage6
    Dim vQuotebtn6
    vQuotebtn6=false
    If rsNewArtApp.Fields("image2").Value <> "" or isnull(rsNewArtApp.Fields("image2").Value) Then
    vQuotebtn6=true
    End If
    If vQuotebtn6=false then
    strQImage6="../siteimgs1/noimage.jpg"
    Else
    If right(Lcase(strQImage6), 3) = "pdf" Then
    strQImage6="../siteimgs1/noimage.jpg"
    Else
    strQImage6="../artappimgs/"&(rsNewArtApp.Fields.Item("Image2").Value)
    End If
    End If
    %>
    <td><div align="center"><A HREF="<%=strQImage6%>" target="_blank"><img src="<%=strQImage6%>" width="100" border="0" class="imageborder" target="_blank"></A></div></td>


  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    Hi eoin,

    Thats still not working. Still bringing up the missing image x. I have changed it to bring up the "noimage.jpg" which works elsewhere on the page but to no avail.

    Here is the complete code with your bit added in.

    *************

    <%
    Dim strQImage6
    Dim vQuotebtn6
    vQuotebtn6=false
    If rsNewArtApp.Fields("image2").Value <> "" or isnull(rsNewArtApp.Fields("image2").Value) Then
    vQuotebtn6=true
    End If
    If vQuotebtn6=false then
    strQImage6="../siteimgs1/noimage.jpg"
    Else
    If right(Lcase(strQImage6), 3) = "pdf" Then
    strQImage6="../siteimgs1/noimage.jpg"
    Else
    strQImage6="../artappimgs/"&(rsNewArtApp.Fields.Item("Image2").Value)
    End If
    End If
    %>
    <td><div align="center"><A HREF="<%=strQImage6%>" target="_blank"><img src="<%=strQImage6%>" width="100" border="0" class="imageborder" target="_blank"></A></div></td>

    Try testing rsNewArtApp.Fields("image2").Value for pdf, your checking strQImage6 in that code


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    kayos wrote: »
    Try testing rsNewArtApp.Fields("image2").Value for pdf, your checking strQImage6 in that code

    Sorry - I wasn't checking the correct variable.


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Nice one lads,

    Got it sorted. here is the finished if your interested

    ********************

    <%
    Dim strQImage6
    Dim vQuotebtn6
    vQuotebtn6=false
    If rsNewArtApp.Fields("image2").Value <> "" or isnull(rsNewArtApp.Fields("image2").Value) Then
    vQuotebtn6=true
    End If
    If vQuotebtn6=false then
    strQImage6="../siteimgs1/noimage.jpg"
    Else
    If right(Lcase(rsNewArtApp.Fields.Item("Image2").Value), 3) = "pdf" Then
    strQImage6="../siteimgs1/pdf.gif"
    Else
    strQImage6="../artappimgs/"&(rsNewArtApp.Fields.Item("Image2").Value)
    End If
    End If
    %>
    <td><div align="center"><A HREF="../artappimgs/<%=(rsNewArtApp.Fields.Item("Image2").Value)%>" target="_blank"><img src="<%=strQImage6%>" width="100" border="0" class="imageborder" target="_blank"></A></div></td>


  • Advertisement
Advertisement