Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

problem reading a pdf in ASP

  • 16-10-2008 2: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,263 ✭✭✭✭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,263 ✭✭✭✭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