cant upload file using phpexcel issue with file path

泪湿孤枕 提交于 2019-12-22 09:49:08

问题


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.

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') ;

kindly help and thanks in advance


回答1:


I suggest you use another solution like this for example:

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


来源:https://stackoverflow.com/questions/6972571/cant-upload-file-using-phpexcel-issue-with-file-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!