The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Getting PDF Size and Posting

Hello,

I don't know if this is JS, but I think the DOM would help do it....

Anyhow... I link to a lot of PDF files statically for a website I maintain. Is there any way to use JS or PHP to find out if the file is a PDF in the link, then add the file size to the link text dynamically?

What happens is when the page loads, it goes away and gets every link within the page. It then checks each link for the existance of pdf. If it finds a file with 'pdf' in it will then use AJAX to go away and load that file. By doing that, the response also returns a Content-Length header which tells us the size of the pdf.

Not sure whether this is the best way, as it has to load each and every PDF file to get its size, but it certainly works.