Skip to main content
Inspiring
August 15, 2008
Answered

Problems with images displaying within document..but no errors

  • August 15, 2008
  • 3 replies
  • 459 views
Hi,
I created a simple CFFile upload page within the admin of a content management system I built. I'm able to upload image files into a designated image directory with no errors.

<cffile action="upload" accept="image/jpg, image/jpeg, image/gif, image/png" nameconflict="makeunique" filefield="imagefile" destination="" />

In a separate area of the CMS I'm using <cf directory> to view and select the images within the directory.

<cfdirectory action="list" directory="" name="rsImages" sort="name" filter="*.jpg" />

Everything seems great and I'm getting no errors. The images are actually being transferred to the web server but they are not appearing within the document. No errors, though. I'm completely stumped. I've tried several things to no avail. Any help is greatly appreciated.

thanks,
Luis

    This topic has been closed for replies.
    Correct answer -__cfSearching__-
    Look at the html source of the page. Copy one of the image urls into a separate browser window. Can you view the image?

    http://yoursite.com/images/staff/someImageFile.jpg

    3 replies

    -__cfSearching__-Correct answer
    Inspiring
    August 15, 2008
    Look at the html source of the page. Copy one of the image urls into a separate browser window. Can you view the image?

    http://yoursite.com/images/staff/someImageFile.jpg
    casegamaAuthor
    Inspiring
    August 15, 2008
    Thanks. It wasn't a CF issuse after all. Just a bad image path on the final display page. I appreciate your help.
    Inspiring
    August 15, 2008
    When you say they do not appear within the document, do you mean an html document, cfdocument, ...? Can you post a snippet of code.
    casegamaAuthor
    Inspiring
    August 15, 2008
    Ultimately I think the problem seems to be in the .cfm file that is public but here are snippets from all involved files.

    within the CMS
    uploadimage.cfm
    <cfif IsDefined ("Form.fieldnames")>
    <cffile action="upload" accept="image/jpg, image/jpeg, image/gif, image/png" nameconflict="makeunique" filefield="imagefile" destination="C:\websites\rc2f7cae\admin\images\staff" />
    </cfif>

    in add.cfm (which creates a new record and assigns the image file to the record..
    <cfdirectory action="list" directory="C:\websites\rc2f7cae\admin\images\staff" name="rsImages" sort="name" />

    and later in the form....
    <td><select name="StaffImage">
    <option value="">No Image</option>
    <cfoutput query="rsImages"><option value="#rsImages.Name#">#rsImages.Name#</option></cfoutput>
    </select>
    </td>

    and finally in staff.cfm (the public document)
    <cfparam name="URL.TypeID" default="2" type="Numeric">
    <cfparam name="PageNum_rsStaffCategory" default="1">
    <cfquery name="rsStaff" datasource="#Request.DSN#">
    SELECT StaffID, StaffTypeID, FullName, Hometown, Bio, StaffImage
    FROM Staff
    WHERE "Online" = 1 AND Staff.StaffTypeID =
    <cfqueryparam value="#URL.TypeID#" cfsqltype="cf_sql_numeric">
    ORDER BY FullName ASC
    </cfquery>
    <cfquery name="rsStaffCategory" datasource="#Request.DSN#">
    SELECT TypeID, TypeName
    FROM StaffTypes
    WHERE "Online" = 1
    ORDER BY TypeName ASC
    </cfquery>
    <cfquery name="rsCurrentType" datasource="#Request.DSN#">
    SELECT TypeID, TypeName
    FROM StaffTypes
    WHERE TypeID =
    <cfqueryparam value="#URL.TypeID#" cfsqltype="cf_sql_clob">
    </cfquery>
    <cfset MaxRows_rsStaffCategory=10>
    <cfset StartRow_rsStaffCategory=Min((PageNum_rsStaffCategory-1)*MaxRows_rsStaffCategory+1,Max(rsStaffCategory.RecordCount,1))>
    <cfset EndRow_rsStaffCategory=Min(StartRow_rsStaffCategory+MaxRows_rsStaffCategory-1,rsStaffCategory.RecordCount)>
    <cfset TotalPages_rsStaffCategory=Ceiling(rsStaffCategory.RecordCount/MaxRows_rsStaffCategory)>

    <table width="100%" border="0" cellpadding="5" cellspacing="5" bgcolor="#F9F9F9">
    <cfoutput query="rsStaff">
    <tr valign="top">
    <td bgcolor="##EFEFEF"><img src="/images/staff/#rsStaff.StaffImage#" alt="#rsStaff.FullName#" /></td>
    <td bgcolor="##EFEFEF"><p><span class="bodycaption">#rsStaff.FullName#</span> #rsStaff.Bio# </p></td>
    </tr>
    </cfoutput>
    </table>
    Inspiring
    August 15, 2008
    casegama wrote:
    > The images are actually being transferred to the web server but they
    > are not appearing within the document. No errors, though.
    > <cfdirectory action="list" directory="" name="rsImages" sort="name" filter="*.jpg" />


    Cfdump the #rsImages# query. Does it contain any records? Is it possible the query is empty because your jpegs have the ".jpeg" extension not ".jpg"?

    BTW, I assume your real code specifies an actual directory not "".

    casegamaAuthor
    Inspiring
    August 15, 2008
    Thanks for the reply. Yes to all of the above. I've used <cfdump> and all files appear. I've experimented with all image file formats. I'm stumped.