新手求助,关于phpexcel的

apcanyue 2017-05-08 02:34:41
用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() ϴļƶλáɹ
...全文
137 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
apcanyue 2017-05-10
  • 打赏
  • 举报
回复
问题已经解决,谢谢帮助了
apcanyue 2017-05-08
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
<? //Excelļ //header("Content-type: text/html; charset=utf-8"); function uploadFile($file,$filetempname) ...... 你用的是短标记,服务器上有配置吗?
没有 刚开的阿里云的服务器 没有修改过
xuzuning 2017-05-08
  • 打赏
  • 举报
回复
<? //Excelļ //header("Content-type: text/html; charset=utf-8"); function uploadFile($file,$filetempname) ...... 你用的是短标记,服务器上有配置吗?

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧