<?php require_once("../../classes/DBConnection.php"); $DB = new DBConnection();
$path_to_folder = "C:\\".trim($_POST['path_to_folder']); $n = 0; $c = 0;

/*ob_start();
echo "<span style='font-size:24px'>{$path_to_folder}</span><br />Pick the downloaded Excel File";
$picturenames = scandir($path_to_folder);
foreach($picturenames as $picturename){
	$ptf = "{$path_to_folder}\\{$picturename}";
	if(strpos($picturename, "(")>-1){ unlink($ptf); $c++; continue; }
	if($picturename!="." && $picturename!=".."){
		$n++;
		//echo "<br />{$picturename}";
	}
}
echo "<br /><hr /><span style='color:#FF2301'>".($c)." file(s) removed</span><br />".($n-2)." file(s) Remaining";
ob_end_flush();*/

//to excel for download
$filename = "Picture Names_" . date('YmdHis') . ".csv";

header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");

$picturenames = scandir($path_to_folder);
foreach($picturenames as $picturename){
	$ptf = "{$path_to_folder}\\{$picturename}";
	if(strpos($picturename, "(")>-1){ unlink($ptf); $c++; continue; }
	if($picturename!="." && $picturename!=".."){ $n++; echo str_replace('.jpg', '', $picturename).",".$picturename."\r\n";}
}
exit;