Answer the question
In order to leave comments, you need to log in
Why can't PHP download the file?
I'm trying to download a regular archive using PHP to the tmp folder. And no matter how you twist it, an empty file is created weighing 0 bytes. The link downloads the file instantly (in the browser). The script thinks for a very long time, in the end it just leaves an empty file. Tried with fopen, curl and file_get_contents. Hosting from reg-ru. Does anyone know what parameter to look for in phpinfo()? There are no errors at the php level. I suspect that the problem is in php modules. Actually the code itself:
$url = "https://any/some.zip";
$local_file = "tmp/some.zip";
$ch = curl_init();
$fp = fopen($local_file, "w");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
Answer the question
In order to leave comments, you need to log in
there is an example here, it seems to be more correct in terms of error handling, although it will be clear what is happening to you.
and your file is on https. See here , it might help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question