|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-09-10 06:16 UTC] niraj at bhawnani dot name
Description: ------------ I spent hours debugging some code I'd written that wasn't working only to find that cURL is behaving strangely. I've taken the minimal parts of that code and put it in this bug report. Basically, if you open a file with fopen, fclose it and then unlink it, it works fine. But if between fopen and fclose, you give the file handle to cURL to do some writing into the file, then the unlink fails. Why this is happening is beyond me. I think it may be related to Bug #48676 I have not had the opportunity to test this on Linux, so I don't know if it's Windows-only. Reproduce code: --------------- <?php $filename = 'tempfile'; $fp = fopen($filename, 'w'); if (!$fp) exit("Failed to open file for writing"); $curl = curl_init('http://bugs.php.net/gifs/logo-bug.gif'); curl_setopt($curl, CURLOPT_FILE, $fp); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); // 10 sec curl_setopt($curl, CURLOPT_TIMEOUT, 600); // 10 mins curl_exec($curl); curl_close($curl); fclose($fp); unlink($filename); ?> Expected result: ---------------- No errors, file unlinks successfully. Actual result: -------------- Warning: unlink(tempfile) [function.unlink]: Permission denied in C:\...\blah.php on line 14 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 05:00:01 2025 UTC |
Could reproduce. <?php $filename = tempnam('/tmp', 'bug49517'); $fp = fopen($filename, 'w'); $curl = curl_init(); curl_setopt($curl, CURLOPT_FILE, $fp); curl_close($curl); fclose($fp); var_dump(is_resource($fp)); // expected: false, because $fp is closed. ?>