0

抱歉问了这么多 [2 天内第 3 次] 这次我想这样做,所以当 ftp_put 上传文件时,它不会在每次上传时都显示结果,比如“Success Success”,但我希望它只在完成时才说上传所有文件。我当前的代码:

 foreach (glob("black/*") as $filename)
 if(ftp_put($conn, $ftpFolder . basename($filename) , $filename, FTP_BINARY)) {
 echo "sall goodman"; }
 else { echo "not goot bruh"; }
} 

[现在不要看答案,它只是为了duh lulz和测试]

提前谢谢你们,你们真的在帮助我:)

4

1 回答 1

0

只需评论该声明,echo "sall goodman"您就可以放心了,这样您就不会收到重复的成功消息。

我已经扩展了您的示例,如果所有文件都成功上传,您会收到消息All files have been successfully uploaded,否则如果有些 2 个文件上传失败,那么您会收到2 file(s) have been failed during upload

$totFiles = 0;
$successUploadFiles=0;
foreach (glob("black/*") as $filename)
 if(ftp_put($conn, $ftpFolder . basename($filename) , $filename, FTP_BINARY)) {
 //echo "sall goodman";
 $successUploadFiles++;
 }
 else { echo "not goot bruh"; }
$totFiles++;
}

if($totFiles == $successUploadFiles)
{
echo "All files have been successfully uploaded";
}
else
{
echo $totFiles-$successUploadFiles." file(s) have been failed during upload";
}
于 2013-09-22T18:46:11.537 回答