PHP头条
热点:

php利用ExcelFileParser把excel导入数据库


这是一款实用的php教程利用excelfileparser把excel导入数据库教程哦。

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>excel数据获取演示</title>
<meta name="keywords" content="todo" />
<meta name="description" content="todo"/>
</head>
<body>
<div>
<div>excel数据获取演示</div>
<div>
<form method="post" action="/index/parse" enctype="multipart/form-data">
<input type="file" name="excel" value="" />
<input type="submit" name="submit" value="提交" />
</form>
</div>
</div>
</body>
</html> 

parese.php文件

 

<?php
/**
* copyright (c) 2009,
* all rights reserved.
* 文件名:
* 摘 要:
*
* @author 星期八 [url=mailto:ixqbar@hotmail.com]ixqbar@hotmail.com[/url]
* @version
*/

public function parse()
{
/**
* $_files数组说明
* array(n) {
* ["表单文件框名称"] => array(5) {
* ["name"] => 提交文件名称
* ["type"] => 提交文件类型 excel为"application/vnd.ms-excel"
* ["tmp_name"] => 临时文件名称
* ["error"] => 错误(0成功1文件太大超过upload_max_filesize2文件太大超过max_file3上传不完整4没有上传文件)
* ["size"] => 文件大小(单位:kb)
* }
* }
*/
$return=array(0,'');
/**
* 判断是否提交
* is_uploaded_file(文件名称)用于确定指定的文件是否使用post方法上传,防止非法提交,通常和move_upload_file一起使用保存上传文件到指定的路径
*/
if(!isset($_files) || !is_uploaded_file($_files['excel']['tmp_name']))
{
$return=array(1,'提交不合法');
}
//处理
if(0 == $return[0])
{
import('@.util.excelparser');
$excel=new excelparser($_files['excel']['tmp_name']);
$return=$excel->main();
}
//输出处理
print_r($return);
?>

www.phpzy.comtrue/php/13422.htmlTechArticlephp利用ExcelFileParser把excel导入数据库 这是一款实用的php教程利用excelfileparser把excel导入数据库教程哦。 !doctype html public -//w3c//dtd xhtml 1.0 transitional//en http://www.w3.org/tr/xhtml1/dtd/xhtml1-transi...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐