续上两篇《上传进度支持(Upload progress in sessions)》和《PHP文件上传进度条基于Session与Javascript实现》后,自己动手调试了一下,遇到几点问题,特记录如下:
1.上传大文件时失败,最后发现PHP.INI中的设置有问题.
upload_max_filesize = 64M
post_max_size = 64M
2.上传页面须打开SESSION.加如下代码.
<?php session_start();?>
3.中文文件上传后显示乱码,须做编码转换.
$name=iconv("UTF-8","gb2312", $filleName)
--------------------upload.php-------------------------------------
<?php
//上传的文件名
$sourceName = $_FILES['file1']['name'];
//对文件名转换后再保存时不会乱码
$targetName=iconv("UTF-8","gb2312", $sourceName);
if(is_uploaded_file($_FILES['file1']['tmp_name'])){
move_uploaded_file($_FILES['file1']['tmp_name'], "./upload/{$targetName}");
}
另注:
本Demo中的原始文件可以到这里下载:Github: pureweber/samples/php-upload-progress