Friday, 6 September 2013

Output URLS to json

Output URLS to json

I want to generate web URLs to files uploaded by users, and serialize
them. In the controller I can do something like:
$myURL = '/' . 'files' . DS . $relationName . DS . 'attachment' . DS .
$attachmentData['dir'] . $attachmentData['attachment'];
But if the filename has spaces, it will not be escaped.
I know I can use the html helper in the view, but this means I will not be
able to use the serialize magic from the controller. And I don't want to
break cake.
I's there a way to create web URLs (h ttp://mydomain.c.../someimage.jpg)
to files in webroot from the controller?

No comments:

Post a Comment