dongxiezhuo8852 2015-12-15 18:08
浏览 43

阅读上传的Excel文件

I am working in PHP. I have moved the uploaded Excel file to a folder on my local server my code is

if(isset($_POST["btnImport"]))
                 {
                      $uploads_dir = 'C:/wamp/www/quiz admin/uploads';
                      $tmp_name = $_FILES["excelFile"]["tmp_name"];
                      $name = $_FILES["excelFile"]["name"];
                    if(!empty($_FILES["excelFile"]["tmp_name"]))
                     {
                        move_uploaded_file($tmp_name, "$uploads_dir/$name");
                        $fileupload = $_FILES["excelFile"]["tmp_name"];                          
                        $fileName = explode(".",$_FILES["excelFile"]["name"]);
                        if($fileName[1]=="xls"||$fileName[1]=="xlsx")
                        {
                        $data = new Spreadsheet_Excel_Reader($name);

The files which I uploaded are moved to "uploads" folder but when I am trying to read these file by using:

                    $data = new Spreadsheet_Excel_Reader($name);  

It returns:

"The filename sample xls.xls is not readable"

what to do ? How to read the uploaded files from the uploads folder ??

  • 写回答

1条回答 默认 最新

  • doumeng3188 2015-12-15 18:27
    关注

    Your script seems to be referencing the $name variable which stores just the name itself but you've moved the file to $uploads_dir/$name.
    Try

    $data = new Spreadsheet_Excel_Reader($uploads_dir.'/'.$name);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭