Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL and curl_setopt- how to remove an option

Tags:

php

curl

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?

like image 410
Lock Avatar asked Dec 26 '22 13:12

Lock


1 Answers

You unset an option by setting the value to null, like so:

curl_setopt($tmp["curl"], CURLOPT_QUOTE, null);
like image 127
David Müller Avatar answered Jan 09 '23 00:01

David Müller