[英]php ftp_get deletes local file on failure
Example: 例:
ftp_get($ftp, 'movies.txt', 'MO'.date('md').'.txt', FTP_ASCII);
if ftp_get
can't find a file MO1115.txt
on remove server and the movies.txt
file exists on local server, it ends up being deleted. 如果
ftp_get
在删除服务器上找不到文件MO1115.txt
并且本地服务器上存在movies.txt
文件,则最终会被删除。 Is this the expected behavior? 这是预期的行为吗?
here is what i found on http://php.net/manual/en/function.ftp-get.php 这是我在http://php.net/manual/en/function.ftp-get.php上找到的内容
*The zero size file is not a side effect. *零大小的文件不是副作用。 When the ftp_get starts the first thing it does is to create the inode/file which it will stream the data too and that is a zero size file with the nname you specified for the local file.
当ftp_get启动时,它首先要做的是创建它将流式传输数据的inode /文件,这是一个零大小的文件,其中包含您为本地文件指定的nname。 When the download fails it leaves the file in place.*
当下载失败时,它会保留文件。*
So i would guess that the best way to handle this is to use a temp file and then check if it was written to or not. 所以我猜想处理这个的最好方法是使用临时文件,然后检查它是否写入。 if yes copy if over the old file, if not simply remove the temp file
如果是复制,如果超过旧文件,如果不是简单地删除临时文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.