Script to execute command to all files in folder

前端 未结 1 1564
悲&欢浪女
悲&欢浪女 2021-01-26 03:35

I am new to Freebsd/nginx, so similar QAs did not help me ;( I was running a code:

$ext = pathinfo ($_FILES[\'rawexcel\'][\'name\'][$i], PATHINFO_EXTENSION);

//         


        
相关标签:
1条回答
  • 2021-01-26 04:18

    See how you extracted the extension...

    $ext = pathinfo ($_FILES['rawexcel']['name'][$i], PATHINFO_EXTENSION);

    You can check the pathinfo docs and you'll see how to get the filename without path or extension:

    $filename = pathinfo($_FILES['rawexcel']['names'][$i], PATHINFO_FILENAME);
    

    Then you can use that...

    if ($ext == 'xlsx' ) {
        exec("/usr/local/bin/cnvt   /var/tmp/xls/$filename.xlsx /var/tmp/$filename.csv ");
    } else if ($ext == 'xls' ) {
        exec("/usr/local/bin/xls2csv -x /var/tmp/xls/$filename.xls -b WINDOWS-1251 -c /var/tmp/$filename.csv -a UTF-8");
    } 
    
    0 讨论(0)
提交回复
热议问题