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

Marc
Mon Feb 7 2011 05:45
This is really interesting, especially on shared hosting or when installing a server on the website it's sometimes really tricky to find those direct paths, so thanks for this nice overview.
bankruptcy attorney
Mon Feb 7 2011 04:24
I just couldnt leave your website before telling you that we really enjoyed the quality information you offer to your visitors… Will be back often to check up on new posts..
blushton
Wed Feb 2 2011 14:06
great code! I had no idea how to directly access these files from my vcloud datacenter. You are an HTML pro, I'll pass this tip onto the rest of my colleagues at work :)






log out