cURL和curl_setopt-如何删除选项 [英] cURL and curl_setopt- how to remove an option

查看:361
本文介绍了cURL和curl_setopt-如何删除选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cURL首先从远程FTP服务器获取文件列表。然后我使用相同的Curl Handle下载该文件。下载后,我再次使用相同的句柄来删除该文件。



当我使用以下代码删除文件时,它会成功:

  curl_setopt($ tmp [curl],CURLOPT_QUOTE,array(DELE。$ tmp [file]))); 

虽然我在日志中得到以下内容:

  [PHP警告] curl_exec():CURLOPT_FILE资源已消失,重设为预设[l:52] 
 <$> c $ c> curl_setopt($ tmp [curl],CURLOPT_FILE,$ tmp [file_handle]); 

我的问题是,如何取消设置我添加的选项?我想删除上面的选项,以便我可以重用curl连接删除文件..或者我设置什么选项基本上取消设置此选项?

解决方案

这对我有用:

  curl_setopt($ tmp [curl],CURLOPT_FILE,STDOUT ); 


I am using cURL to firstly get a list of files from a remote FTP server. I then use the same Curl Handle to download that file. After the download, I then once again use the same handle to remove the file.

When I use the following code to remove the file, it does succeed:

curl_setopt($tmp["curl"], CURLOPT_QUOTE, array("DELE " . $tmp["file"]));

although I get the following in the logs:

[PHP Warning] curl_exec(): CURLOPT_FILE resource has gone away, resetting to default [l:52]

The reason is that when I first downloaded the file, I set the following option:

curl_setopt($tmp["curl"], CURLOPT_FILE, $tmp["file_handle"]);

My question is, how do I unset options that I have added? I want to remove the above option so that I can reuse the curl connection to delete the file.. or what option to I set to basically unset this option?

解决方案

This worked for me:

curl_setopt($tmp["curl"], CURLOPT_FILE, STDOUT);

这篇关于cURL和curl_setopt-如何删除选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆