用phpexcel做的excel的导入和导出,经过测试,在本地上和同事的电脑上都能导入,但是上传到服务器空间上的时候就不能用了,点击后就是就是无法显示,最初的时候是错误500,后来调试的没有500了,但是也没有错误提示了,还是不能上传表格数据到数据库中,后测试,发现
与本地的
本人初学,对于phpexcel的了解的不多,不知道这是哪里出错了
下面是处理上传文件功能的代码
<?php
error_reporting(0);
//header("Content-type: text/html; charset=utf-8");
include 'conn/conn.php';
include 'sheyingfunction.php';
mysql_query("set names 'utf8'");
$a = $_POST['import'];
//echo $a;//exit;
if($a == "摄影团导入数据"){
$leadExcel=$_POST['leadExcel'];
//echo $leadExcel;//exit;
if($leadExcel == "true")
{
$filename = $_FILES['inputExcel']['name'];
echo $filename;//exit;
$tmp_name = $_FILES['inputExcel']['tmp_name'];
echo $tmp_name;//exit;
$msg = uploadFile($filename,$tmp_name);
print_r($msg);//exit;
if($msg == 1){
echo '<script language = javascript>alert("摄影团文件导入成功");window.location.href="daoru.php"</script>';
} else {
echo '<script language = javascript>alert("摄影团文件导入失败");window.location.href="daoru.php"</script>';
}
}
}
?>
在下面处理文件的代码就是在数据库写入数据的
<?
//Excelļ
//header("Content-type: text/html; charset=utf-8");
function uploadFile($file,$filetempname)
{
//自己设置的上传文件存放路径
$filePath = 'upFile/';
$str = "";
//下面的路径按照你PHPExcel的路径来修改
set_include_path('.'. PATH_SEPARATOR .'PHPExcel' . PATH_SEPARATOR .get_include_path());
require_once 'PHPExcel.php';
require_once 'PHPExcel\IOFactory.php';
//require_once 'PHPExcel\Reader\Excel5.php';//excel 2003
require_once 'PHPExcel\Reader\Excel2007.php';//excel 2007
$filename=explode(".",$file);//把上传的文件名以“.”好为准做一个数组
$time=date("y-m-d-H-i-s");//去当前上传的时间
$filename[0]=$time;//取文件名t替换
$name=implode(".",$filename); //上传后的文件名
$uploadfile=$filePath.$name;//上传后的文件名地址
//move_uploaded_file() ϴļƶλáɹ