php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51890 CURL Problem
Submitted: 2010-05-22 23:10 UTC Modified: 2010-06-01 12:06 UTC
From: seizu at gmx dot at Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.3.2 OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: seizu at gmx dot at
New email:
PHP Version: OS:

 

 [2010-05-22 23:10 UTC] seizu at gmx dot at
Description:
------------
The script copy the URL into an existing file (robot.txt)
The error occurs when you run the test script from the command line 
by providing the absolut path of your php.exe like

>c:\php\php.exe test.php

When you don't provide the absolut php path, the problem does not occure

>php test.php








Test script:
---------------
<?php

$outfile="c:\\robots.txt";
$infile="http://www.astrobox.at/robots.txt";
$ch = curl_init($infile);
$fo = fopen($outfile, "rb+" );
curl_setopt($ch, CURLOPT_FILE, $fo);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fo);

?>

Expected result:
----------------
nothing

Actual result:
--------------
C:\phpda>c:\php\php.exe C:\phpda\test.php
PHP Warning:  curl_setopt(): the provided file handle is not writable in C:\phpda\test.php on line 7

Warning: curl_setopt(): the provided file handle is not writable in C:\phpda\test.php on line 7
User-agent: *
Disallow: /administrator/
Disallow: /cache/
Disallow: /components/
Disallow: /editor/
Disallow: /help/
Disallow: /images/
Disallow: /includes/
Disallow: /language/
Disallow: /mambots/
Disallow: /media/
Disallow: /modules/
Disallow: /templates/
Disallow: /installation/
Disallow: /astrobox/produkte/
Disallow: /option/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-23 19:40 UTC] felipe@php.net
-Package: Scripting Engine problem +Package: cURL related
 [2010-05-29 07:59 UTC] kalle@php.net
-Status: Open +Status: Bogus
 [2010-05-29 07:59 UTC] kalle@php.net
You cannot do a writable operation using CURLOPT_FILE when the file pointer is opened with 'r', use 'wb+' instead of 'rb+'.
 [2010-05-29 11:05 UTC] seizu at gmx dot at
When you write into an "EXISTING FILE" "rb+" should work

apart from that, the script works if you dont provide an absolute php-path!
 [2010-06-01 12:06 UTC] seizu at gmx dot at
--snip--
docu fopen

'r+'  	 Open for reading and writing; place the file pointer at the beginning of the file.

'w+' 	Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. 
--snip--

when I use "wb+" the existing file will be truncate and that is not what I want, so I have to use "rb+" anyway

...and sorry, it has nothing to do with the absolute php-path it just a problem 
with php versions >5.2.8
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC