Finding the direct path (URL) to a file uploaded in an HTML object

Published: Tuesday, November 3, 2009

Updated: Wednesday, August 11, 2010 12:08

You can use HTML objects to store files, such as PDFs, .docs, .mp3s and more within the CP5 system. These files are then accessible anywhere through a Web address or URL.

If you look at the HTML object and look under its FILES tab, you'll see a string of code that gives an example for linking to an uploaded image within an HTML image tag. This code, below, will write the URL to an uploaded file specified.

<img alt="" src="#file({'filename': 'logo.png', 'contentId': $content.contentId, '':''})" />

In this case, the uploaded file was "logo.png." The img tag would then display the image (logo.png) at the URL the system wrote. Note that the sampled code is to display an image. only the characters between the quotes in src="" are needed to tell the system to write the URL itself:

#file({'filename': 'logo.png', 'contentId': $content.contentId, '':''})

This code will only work in the HTML tab of the HTML object that the file is uploaded to. The following example will provide you the full URL In short, the URL structure will look like this:

http://domain.com/polopoly_fs/ELEMENTID!/FILE.EXT

So, for an mp3 we upload to an HTML object, we'll first look in the upper-right corner of the HTML object while it's open. You'll see an ID: followed by a number, for example "ID: 1.1299." Let's say we uploaded "call.mp3" to that HTML object. The URL to access the file will be:

http://www.domain.com/polopoly_fs/1.1299!/call.mp3

Where domain.com is your site.

You can then use this URL to link or call any file from anywhere within your site or the Internet.

Recommended: Articles that may interest you

21 comments







log out