Heim  >  Artikel  >  Backend-Entwicklung  >  php实现上传Excle文件

php实现上传Excle文件

WBOY
WBOYOriginal
2016-06-23 14:12:321629Durchsuche

PHP Excel

要实现php上传EXCEL时,在选择文件时,只显示EXCEL文件,还有就是如何判断$upfile=$_FILES["upfile"];$type = $upfile["type"]; $type是excel的, 我试过$type=="xls"不行,它应该等于什么,还有一个问题就是上传时,不是都是先把文件上传到一个临时文件,然后在移动到指定目标,这个临时文件怎么删除

回复讨论(解决方案)

1、$upfile["type"]:

xla application/vnd.ms-excel 
xlc application/vnd.ms-excel 
xll application/x-excel 
xlm application/vnd.ms-excel 
xls application/vnd.ms-excel 
xlt application/vnd.ms-excel 
xlw application/vnd.ms-excel 

2、临时目录不用你管,上传程序执行完系统会自动删除临时文件。

1、$upfile["type"]:

xla application/vnd.ms-excel 
xlc application/vnd.ms-excel 
xll application/x-excel 
xlm application/vnd.ms-excel 
xls application/vnd.ms-excel 
xlt application/vnd.ms-excel 
xlw application/vnd.ms-excel 

2、临时目录不用你管,上传程序执行完系统会自动删除临时文件。
这些都是excle格式的吗,只要$type="application/vnd.ms-excel"这样吗

我是写个这个?
witch ($type) {
case 'xla application/vnd.ms-excel ' : $ok=1;
break;
case 'xlc application/vnd.ms-excel' : $ok=1;
break;
case 'xll application/x-excel ' : $ok=1;
break;
case ' xlm application/vnd.ms-exce' : $ok=1;
break;
case 'xls application/vnd.ms-excel' : $ok=1;
break;
case 'xlt application/vnd.ms-excel' : $ok=1;
break;
case 'xlw application/vnd.ms-excel' : $ok=1;
break;

}

判断扩展名吧

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn