Viewers > Displaying Uploads
For most content fields you only need a single tag to display their value.
Because uploads have more information (url, height, width, etc) they work a
The Page Viewer Generator will generate a block of code that display uploads. It looks something like this:
<!-- STEP3: Display Uploads -->
<?php foreach ($record['uploads'] as $upload): ?>
... uploads are displayed here ...
<?php endforeach ?>
<!-- STEP3: /Display Uploads -->
and inside that block you can display upload fields like this:
<?php echo $upload['urlPath'] ?>
Note: The default "List Viewer" code doesn't
include any upload fields. This keeps those pages shorter and easier to work
with. If you want to display uploads on the list page, simply copy the code from the
Here is an exampled of code used to display image thumbnails:
<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $upload[info1] ?>" title="<?php echo $upload[info2] ?>"/>
<?php endif ?>
<?php endforeach ?>
Here's a list of upload fields.
- All uploads
All uploaded files have the following attributes, whether they are images or documents.
- filePath - the server path to the uploaded file, e.g. C:\www\example.com\cmsadmin\uploads\foo.gif, /vhosts/example.com/htdocs/cmsadmin/image.jpg
- urlPath - the website location of the uploaded file, e.g. /cmsadmin/uploads/image.jpg
- filename - image.jpg
- extension - jpg
Custom Info Fields
- info1, info2, info3, etc. - You can define these extra Info Fields in the program (by default, info1 is "Title" and info2 is "Caption"). You might use these fields to generate alt text for images, descriptions of uploaded files, or captions for images in a photo gallery.
To modify the labels for these extra fields, go to Admin > Section Editors, and click "modify" for the upload field. In the "Advanced" section, you'll find the Info Fields.
- Image files
- hasThumbnail - Set to "1" if upload is an image and a thumbnail exists.
- width - the width of the image
- height - the height of the image
- thumbFilePath - as per "filepath" above, but references the thumbnail created by the program for the uploaded image
(for additional thumbnails use thumbFilePath2 - thumbFilePath4)
- thumbUrlPath - as per "urlPath" above, but references the thumbnail created by the program for the uploaded image
(for additional thumbnails use thumbUrlPath2 - thumbUrlPath4)
- thumbWidth - the width of the thumbnail
(for additional thumbnails use thumbWidth2 - thumbWidth4)
- thumbHeight - the height of the thumbnail
(for additional thumbnails use thumbHeight2 - thumbHeight4)
- Misc. Attributes
- Note: The following attributes are used by the program, but are included in these docs for the sake of completeness...
- num - a unique number that identifies this upload
- createdTime - the date the upload was added
- tableName - the table name the upload is associated with
- fieldName - the field name the upload is associated with
- recordNum - the record number the upload is associated with
- preSaveTempId - a temporary id used to identify uploads when creating new records