2010-06-29 65 views

回答

1

,您可以:

  • 崗位目錄中的所有文件,因此

  • 壓縮的目錄和上傳檔案

+1

我想你的意思是連續http://www.merriam-webster.com/netdict/consecutively – 2010-06-29 14:15:04

0
$srcdir = '/source/directory/'; 
$dh = opendir($srcdir); 

$c = curl_init(); 
curl_setopt($c, ....); // set necesarry curl options to specify target url, etc... 

while($file = readdir($dh)) { 
    if (!is_file($srcdir . $file)) { 
     continue; // skip non-files, like directories 
    } 
    curl_setopt($c, CURLOPT_POSTFIELDS, "[email protected]{$srcdir}{$file}"); 
    curl_exec($c); 
} 
closedir($dh); 

這會是基礎。您需要在那裏進行一些錯誤處理,以確保源文件可讀,確保上傳成功等。完整的CURLOPT常量集記錄在文件here中。

+0

怎麼樣在一個請求中發佈多個文件?你可以在一個請求中發佈一組文件嗎? – 2010-07-02 16:52:58

+0

只需將POSTFIELDS setopt調用更改爲'file1 = @ ...&file2 = @ ...&file3 = @ ...'。 – 2010-07-03 13:34:24