php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74280 CURLOPT_FILE not work in curl_setopt_array
Submitted: 2017-03-21 09:11 UTC Modified: 2017-03-21 11:30 UTC
From: luutruong1992 at gmail dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.6.30 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
11 + 35 = ?
Subscribe to this entry?

 
 [2017-03-21 09:11 UTC] luutruong1992 at gmail dot com
Description:
------------
I have try to downloading an file from remote URL but the file was empty while i using this code.
$url = 'http://some_url...';

$tempFile = 'output_file.data';
$fp = fopen($tempFile, 'w+');

$options = [
	CURLOPT_URL => $url,
	CURLOPT_FILE => $fp,
	CURLOPT_FOLLOWLOCATION => 1,
	CURLOPT_RETURNTRANSFER => 1
];

$ch = curl_init();
curl_setopt_array($ch, $options);

curl_exec($ch);
curl_close($ch);

fclose($fp);
?>

But when  I split CURLOPT_FILE to another method.
curl_setopt($ch, CURLOPT_FILE, $fp);

it is working property.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-21 11:30 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-03-21 11:30 UTC] requinix@php.net
CURLOPT_FILE (output goes to a file) and CURLOPT_RETURNTRANSFER (output goes to a string) are mutually exclusive.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC