PHP 在线预览word、excel、ppt、pdf、txt等文档文件


// PDF、text可以直接网页打开查看
// word、excel、ppt 文件可以通过office官方打开
$fileType = strrchr($fileUrl,'.');//获取文件类型
if($fileType == 'PDF' || $fileType =='txt'){
//直接网页中打开
}else if($fileType == 'doc' || $fileType =='docx' || $fileType =='xlsx' || $fileType =='xls'){
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://view.officeapps.live.com/op/view.aspx?src='.$fileUrl);//fileUrl 必须是绝对路径
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM