gt_1992 2016-04-27 00:56 采纳率: 0%
浏览 2668

使用PHPExcel导入时,报500错误,求大神给看看

require_once ('PHPExcel.php');
require_once ('PHPExcel/IOFactory.php');
require_once ('PHPExcel/Reader/Excel5.php');

if($_POST['leadExcel'] == "true")
{

$filename = $_FILES['inputExcel']['name'];
$tmp_name = $_FILES['inputExcel']['tmp_name'];
//自己设置的上传文件存放路径
$filePath = '../../upfile/';
$str = "";
//注意设置时区
$time=date("y-m-d-H-i-s");//去当前上传的时间
//获取上传文件的扩展名
$extend=strrchr($filename,'.');
//上传后的文件名
$name=$time.$extend;
$uploadfile=$filePath.$name;//上传后的文件名地址
//move_uploaded_file() 函数将上传的文件移动到新位置。若成功,则返回 true,否则返回 false。

$result=move_uploaded_file($tmp_name,$uploadfile);//假如上传到当前目录下

if($result) //如果上传文件成功,就执行导入excel操作
{               
    $objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
    $objPHPExcel = $objReader->load($uploadfile);
    $objWorksheet = $objPHPExcel->getActiveSheet();
    $highestRow = $objWorksheet->getHighestRow();
    $highestColumn = $objWorksheet->getHighestColumn();
    $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);//总列数
    $headtitle=array();
    for ($row = 2;$row <= $highestRow;$row++)
    {
        $strs=array();
        //注意highestColumnIndex的列数索引从0开始
        for ($col = 0;$col < $highestColumnIndex;$col++)
        {
            if($col==3){
                $strs[$col] =excelTime($objWorksheet->getCellByColumnAndRow($col, $row)->getValue());
            }else{
                $strs[$col] =$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
            }   
        }
        $sql = "INSERT INTO phonecard(batch, cardpwd, fee, outdate, cardno,status) VALUES (
        '{$strs[0]}',
        '{$strs[1]}',
        {$strs[2]},
        '{$strs[3]}',
        '{$strs[4]}',
        {$strs[5]})";
        $res=$user->InsertCard($sql);           
        if(!$res)
        {
            return false;
            echo 'sql语句有误';
        }else{
            $str = "";
        }
    }           
    unlink($uploadfile); //删除上传的excel文件
}       
echo "<script>alert('导入成功!');window.location.href='huiyuanlist.php'</script>";

}

  • 写回答

1条回答

  • devmiao 2016-04-27 00:58
    关注

    http://www.jb51.net/article/43737.htm
    500是服务器错误,检查下

    评论

报告相同问题?

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题