Thursday, February 21, 2013

Re: Link to PDF? Yikes!

Assuming your files really are in app/webroot/...

On Wednesday, 20 February 2013 15:05:00 UTC+1, April DeRossett wrote:
I have read, and read, but I can not figure this out.  I am hoping someone will point me in the right direction.  I have .pdf resources in app/files/id#/../..  To which I need to link.

It's not clear from your example but a url fragment (#) is never sent to a server. so if you're using # in urls (terrible idea) you need to escape it, otherwise the server will only see /files/id irrespective of what's at the end of the url

if you're not using # in the url - you simply have the path wrong:

    path/to/app/webroot/files/some/folder/whatever/foo.pdf
    url starts here ...^

i.e. requesting example.com/files/some/folder/whatever/foo.pdf will work.

Use the Html helper or simply, the router to ensure you get the path right:

    $url = Router::url('/files/some/folder/whatever/foo.pdf');

    $link = $this->Html->link('A pdf', '/files/some/folder/whatever/foo.pdf');

On Wednesday, 20 February 2013 15:05:00 UTC+1, April DeRossett wrote:
Okay...the end path will be variable so a route won't work

That's what routes are for ...?

AD 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: