|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2009-07-17 12:10 UTC] trutas dot ctx at gmail dot com
 Description:
------------
is_readable() returns false for temporary file (just created) "C:\WINDOWS\Temp\dom373.tmp" and filezise() fails too.
fopen() and get_file_contents() both work for the same file.
as a workaround i'm using fopen() instead of is_readable() and 
fseek($fopen_instance, 0, SEEK_END); instead of filesize()
Reproduce code:
---------------
//temporary location
$resolved_url = tempnam(DOMPDF_TEMP_DIR, "dompdf_img_");
//get source
$image=my_file_get_contents("http://9tree.net/favicon.ico");
//save it
file_put_contents($resolved_url, $image);
//tests
if(is_readable($resolved_url)) print "file readable, ";
if(filesize($resolved_url)) print "filezise found.\n";
die("all done.");
Expected result:
----------------
file readable, filezise found.
all done.
Actual result:
--------------
all done.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 00:00:01 2025 UTC | 
I'm sorry for the DOMPDF_TEMP_DIR, Initially this problem was discovered when using dompdf in this environment - file_get_contents was a proxy workaround. I have fully tested this version: Reproduce code: --------------- <?php //temporary location $resolved_url = tempnam("/tmp", "test_"); //get source $image=file_get_contents("http://9tree.net/favicon.ico"); //save it file_put_contents($resolved_url, $image); //tests if(is_readable($resolved_url)) print "file readable, "; if(filesize($resolved_url)) print "filezise found."; ?> In Unix/Win32 it works perfectly. This is only happening in Windows Server 2003 x64 IIS 6.0 where tempnam("/tmp", "test_") returns something like "C:\WINDOWS\Temp\tes20FB.tmp". in the case of filesize i get a warning - "stat failed for C:\WINDOWS\Temp\tes20FB.tmp ..." Regards, Carlos