这是一款实用的php教程利用excelfileparser把excel导入数据库教程,代码如下:
<!doctype html> <html> <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); ?>
文章链接:
随便收藏,请保留本文地址!
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Where to find the Crane Control Keycard in Atomfall
3 weeks agoByDDD
Roblox: Dead Rails - How To Complete Every Challenge
4 weeks agoByDDD
Atomfall guide: item locations, quest guides, and tips
4 weeks agoByDDD

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools