I have a simple PHP script that scans an entire directory and uploads all files. But I want it to upload the folders aswell. (and keep the folder structure) How do I do that?
My code:
$dir = 'Test/';
$di = new RecursiveDirectoryIterator($dir);
$ch = curl_init('https://website.com');
curl_setopt($ch, CURLOPT_URL,'https://website.com');
curl_setopt($ch, CURLOPT_POST,1);
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
echo $filename;
$cFile = curl_file_create($filename);
$post = array('file'=> $cFile);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
}
curl_close ($ch);