tags:

views:

43

answers:

2

I'm using the zend framework. From within my phtml file, I am trying to call a link to a swf file that is outside of my web directory. The code for this link is:

<?php echo getcwd(); ?>  
<object width="550" height="400">  
<param name="movie" value="somefilename.swf">  
<embed src="/message/get-file/messageId/<?php echo $this->message->id; ?>" width="550" height="400">  
</embed>  
</object>

The readfile($fileName); code opens a save file box that successfully saves the file and is larger than 1KB. I feel like I'm missing something basic?

Just to confirm, I can with images but not flash? Is this right?

`header("Content-Type: image/jpg");  
header("Content-Disposition: attachment; filename=$fileName");  
readfile($fileName);`  

I then used :
<img src='/message/get-file/messageId/<?php echo $this->message->id; ?>'

This worked fine

I was hopping to do something like
header("Content-Type: application/x-shockwave-flash",true);
header("Content-Disposition: attachment; filename=$fileName"); readfile($fileName);

And then
<embed src="/message/get-file/messageId/<?php echo $this->message->id; ?>"

+1  A: 

You can't link to files outside of your publicly accessible document root, regardless of whether the PHP script has access to the file server-side.

meagar
A: 

Big thank you to Meagar for answering.
You were right that I did not giving a complete example and I'm sorry about that.
I found the answer and it was that I was sending the wrong header.
What I was sending was:

header("Content-Disposition: attachment; filename=$message->file_name");

It should have been:

header("Content-Disposition: inline; filename=$message->file_name");

The full thing is:

header("Content-Type: application/x-shockwave-flash",true);
header("Content-Length: {strlen($fileName)}",true);
header("Accept-Ranges: bytes",true);
header("Connection: keep-alive",true);
header("Content-Disposition: inline; filename=$message->file_name");
readfile($fileName);

richie