扫码关注官方订阅号
在做一个文件的上传与输出,现在已经实现了文件的上传了,但是输出不知道怎么输出来。在数据库中已经保留了文件的路径,我想在页面上输出文件名,然后点击文件名就可以查看文件的全部内容,怎么实现呀?
出现乱码一般都是编码问题,要先确定你读取文件的编码,再做转化
$str = file_get_contents("./1.txt"); $encod = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); $str = iconv($encod ,'UTF-8' ,$str); echo $str;
file_get_contents(filename)
试试
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
出现乱码一般都是编码问题,要先确定你读取文件的编码,再做转化
$str = file_get_contents("./1.txt"); $encod = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); $str = iconv($encod ,'UTF-8' ,$str); echo $str;file_get_contents(filename)
试试