在php中使用CURL下载文件夹

时间:2015-05-22 11:52:04

标签: php curl libcurl

所以我使用curl:

在服务器上上传了一个文件夹.zip
function uploadCurs(){
   $ch = curl_init("http://myServer.com/service.php");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_POST, true);
   curl_setopt($ch, CUROPT_POSTFIELDS, "archive = ".NOM_OF_ARCHIVE);
   echo curl_exec($ch);
}

现在,如何测试是否上传成功以及如何下载.zip? 请帮帮我!!! Thx提前

1 个答案:

答案 0 :(得分:1)

您可以使用file_exists函数。 See here for manual

你可以这样做:

<?php
    $filename = '/path/to/foo.zip';

    if (file_exists($filename)) {
        echo "The file $filename exists";
    } else {
      echo "The file $filename does not exist";
    }
?>