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);
//get extension of file, run different converters depending on extension
if ($ext == 'xlsx' ) { exec("/usr/local/bin/cnvt /var/tmp/xls/result.xlsx /var/tmp/result.csv "); }
else
if ($ext == 'xls' ) { exec("/usr/local/bin/xls2csv -x /var/tmp/xls/result.xls* -b WINDOWS-1251 -c /var/tmp/result.csv -a UTF-8"); }
/var/tmp/xls/
when my file names were constant(result.xls which then converted to result.csv) & I was processing files one by one; cnvt and xls2csv are converters. Now I have ajax upload and want to perform exec command for all files in a folder, keeping original file name. I tried to run same code with result.xls replaced with *(star) but it did not work.
what I have:
folder tmp/xls with excel files
what I want:
convert all excel files inna folder to .csv keeping their original names. Will appreciate any help.
UPDATE: the best way to execute a command for all files in directory to create/edit a script to make that, operating on all files in directory much easier in bash itself. Good luck.
See how you extracted the extension...
You can check the pathinfo docs and you'll see how to get the filename without path or extension:
Then you can use that...