无法使用phpexcel文件路径上传文件 [英] cant upload file using phpexcel issue with file path

查看:125
本文介绍了无法使用phpexcel文件路径上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用phpexcel库读取要由用户上传的我的excel文件.但是我现在不能:(

i am currently using phpexcel library to read my excel file which is to be uploaded by user . but i cannot at this moment :(

我正在使用此代码,目前无法正确获取文件路径,如果有人可以告诉我,如何跳过现有文件并重命名输入文件.

i am using this code, i cannot get the file path right at this moment and if some one could tell me , how to over ride existing file and renaming the input file.

文件正在传输到文件夹,但是我在此行中无法获得正确的路径名$ objPHPExcel = $ objReader-> load('upload/'.$ test);有谁能帮助我吗?

file is being transferred to folder , but i cant get the path name correct in this line $objPHPExcel = $objReader->load('upload/'.$test);can any one help me ?

move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
$test= $_FILES["file"]["name"];
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
require_once('classes/phpexcel.php');
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load('upload/'.$test);
$objWorksheet = $objPHPExcel->setActiveSheetIndex('0') ;

请提前帮助和感谢

推荐答案

我建议您使用其他类似的解决方案,例如:

I suggest you use another solution like this for example:

$objPHPExcel = PHPExcel_IOFactory::load("/upload/" . $_FILES["file"]["name"]);
$objPHPExcel->setActiveSheetIndex(0);

这篇关于无法使用phpexcel文件路径上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆