php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42248 filesize() on symlink returns size of the file pointed by it.
Submitted: 2007-08-08 13:11 UTC Modified: 2007-08-09 23:28 UTC
From: mahesh dot vemula at in dot ibm dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5CVS-2007-08-08 (snap) OS: RHEL4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mahesh dot vemula at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-08-08 13:11 UTC] mahesh dot vemula at in dot ibm dot com
Description:
------------
When filesize() is applied on a symbolic link to a file, it returns the size of the file pointed by it instead of returning the size of symlink itself. This is happening for both php5 and php6. Is this the valid behavior?

Reproduce code:
---------------
<?php
$file_handle = fopen("test.tmp", "w");
fwrite( $file_handle, str_repeat("Hello World, this is 2007 year ....\n", 100) );
fclose($file_handle);

symlink("test.tmp", "test_symlink.tmp");  //creating symlink

var_dump( filesize("test_symlink.tmp") );  //size of the symlink itself
clearstatcache();
var_dump( filesize("test.tmp") );  //size of the file
clearstatcache();

unlink("test_symlink.tmp");
unlink("test.tmp");
?>


Expected result:
----------------
-sizeof(symlink)-
int(3600)

Actual result:
--------------
int(3600)
int(3600)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-09 23:28 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 22:01:36 2025 UTC