开发者

How to call an swf file using php?

开发者 https://www.devze.com 2023-01-21 23:00 出处:网络
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.

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/mes开发者_如何学编程sageId/<?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; ?>"


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.


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);

0

精彩评论

暂无评论...
验证码 换一张
取 消