appended to $path. The issue appears to be that is_dir() can take a
relative path.
On Fri, May 1, 2009 at 5:04 PM, bram <brammeleman@gmail.com> wrote:
>
> Did you try 'name' => 'test' (without extension)?
>
> I don't know why the parameters to the media view are that
> complicated... note that the extension should be lower case. In my
> application, the absolute path to the file is known. Even then, it's
> quite a hassle to get in properlly in the media template. I've used
> the following code:
>
> $path_parts = pathinfo($filepath);
>
> $params = array();
> $params['id'] = $path_parts['basename'];
> $params['name'] = $path_parts['filename'];
> $params['extension'] = strtolower($path_parts['extension']);
> $params['path'] = $path_parts['dirname'] . DS;
> $params['download'] = true;
>
>
> On Apr 21, 6:30 am, brian <bally.z...@gmail.com> wrote:
>> Mediaviewkeeps throwing up a 404 because of the following code:
>>
>> if (is_dir($path)) {
>> $path = $path . $id;} else {
>>
>> $path = APP . $path . $id;
>>
>> }
>>
>> if (!file_exists($path)) {
>> header('Content-Type: text/html');
>> $this->cakeError('error404');
>>
>> }
>>
>> Here are my params, btw:
>>
>> Array
>> (
>> [id] => test.jpg
>> [name] => test.jpg
>> [download] => 1
>> [extension] => jpg
>> [path] => files/test/
>> )
>>
>> That path is under APP, not WWW_ROOT, as it should be.
>>
>> What's happening is that is_dir() can take a relative path and so is
>> checking relative tp APP and returning true. However, file_exists()
>> must have an absolute path.
>>
>> When I changed my code to:
>> 'path' => APP.$result['ItemFile']['directory'].DS
>>
>> Everything worked.
>>
>> I didn't see anything on bugtrac. Shouldn't this problem be cropping
>> up for everybody that uses the recommended relative-to-app path?!?
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment