简体   繁体   中英

Access html files / video files outside htdocs folder

Trying to protect video files that are done in camtsia which outputs html/with flash embed video files.

Not sure how I would access them using PHP. I've searched stackoverflow and found using alias would be an option? Is that still secure though? Is that the best way to go? Or should I try to purue a file open operations using PHP.

It needs to serve an html page which has.js.swf files along in the same protected dir.

Any help or direction is appreciated.

You would use readfile to access the file and the header function to forge the content. Make sure the www-data user, which is the Apache user and PHP uses it to access the filsystem, has permission on that folder.

header('Content-type: video/avi');
header('Content-Disposition: attachment; filename="videodownload.avi"');
readfile('/var/videos/myvideo.avi');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM