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 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:
22 + 4 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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 Mar 28 19:01:29 2024 UTC