开发者

PHP file download with symlinks

I have a bunch of .tgz files that are made accessible via. symlinks. When I click on the href on my page pointing to the symlink, it downloads a rather strange file. The downloaded file has the name of the symlink, and upon opening the archive I get (from what I can tell) a binary file, which may or may not be to contents of the static file.

What I'd like to do is get PHP to show a file download dialogue that gives the file linked by the symlink, not the actual symlink. Is that poss开发者_如何学JAVAible?


Well to give you an exact answer I would need to know more about how you serve the file. Why is php even involved? isn't the file served by the webserver? Do you redirect to it or read it into memory in your php script from where you print it?

But I can tell you this.

PHP does in most cases handle symlinks as files, and doesn't samlessly serve the file behind the link.

There are the php functions is_link() to check if a resource pointer is a link, there is the function readlink() to serve the file behind a link and there is linkinfo() which gives you information about the link.

But most likely you need to explicitly allow Apache or whatever server you are using to follow symlinks which can be dyne witht he Options FollowSymLinks directive in apache.


PHP has readlink that allow you get the path that it targeted/linked to.
However, think your problem is related to apache rewrite, or absolute path (again)

PS : did tgz extensions supported by your apache mime?

refer : http://www.w3schools.com/media/media_mimeref.asp

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜