【发布时间】:2017-04-08 03:29:50
【问题描述】:
我有一个简单的 PHP 脚本,它可以扫描整个目录并上传所有文件。但我希望它也能上传文件夹。 (并保持文件夹结构)我该怎么做?
我的代码:
$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);
【问题讨论】: