php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48975 symlink under windows 7 problem
Submitted: 2009-07-19 07:41 UTC Modified: 2009-09-28 20:25 UTC
From: celkaprog at gmail dot com Assigned: pajoye
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.0 OS: win32 only - Windows 7
Private report: No CVE-ID:
 [2009-07-19 07:41 UTC] celkaprog at gmail dot com
Description:
------------
Hi
I am using PHP 5.3.1.0 and Windows 7
Symlink doesn't work for me:

Warning: symlink() [function.symlink]: Could not fetch file 
information(error 3) in E:\htdocs\foo\bar\tree_copy.php on line 148


(5.3.0	 This function is now available on Windows platforms (Vista, 
Server 2008 or greater).)

What are the error codes?

Reproduce code:
---------------
---
From manual page: function.symlink
---
if (is_readable("../../foo/bar/2.jpg")) echo "readable";
symlink("../../foo/bar/2.jpg","../../foo/bar/1.jpg");

../../foo/bar/1.jpg is exists and the path is correct.




Expected result:
----------------
readable
2.jpg what is symlink for 1.jpg.

Actual result:
--------------
readable
Warning: symlink() [function.symlink]: Could not fetch file 
information(error 3) in E:\htdocs\foo\bar\tree_copy.php on line 148
and no 2.jpg

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-19 07:43 UTC] celkaprog at gmail dot com
Description:
------------
Hi
I am using PHP 5.3.1.0 and Windows 7
Symlink doesn't work for me:

Warning: symlink() [function.symlink]: Could not fetch file 
information(error 3) in E:\htdocs\foo\bar\tree_copy.php on line 148

(5.3.0	 This function is now available on Windows platforms (Vista, 
Server 2008 or greater).)

What are the error codes?

Reproduce code:
---------------
---
From manual page: function.symlink
---
if (is_readable("../../foo/bar/1.jpg")) echo "readable";
symlink("../../foo/bar/2.jpg","../../foo/bar/1.jpg");

../../foo/bar/1.jpg is exists and the path is correct.

Expected result:
----------------
readable
2.jpg what is symlink for 1.jpg.

Actual result:
--------------
readable
Warning: symlink() [function.symlink]: Could not fetch file 
information(error 3) in E:\htdocs\foo\bar\tree_copy.php on line 148
and no 2.jpg
 [2009-07-19 07:45 UTC] celkaprog at gmail dot com
Sorry for the double post but one important thing is written wrong in my 
letter.(if (is_readable("../../foo/bar/2.jpg")) echo "readable";)
(/foo/bar/1.jpg is the correct and i use it in my code not 2.jpg)
 [2009-07-19 11:19 UTC] pajoye@php.net
Do you run it under an elevated user?
 [2009-07-19 11:22 UTC] celkaprog at gmail dot com
No,it's running with my account.No service.I can write that folder with php (file upload is working too there).
 [2009-07-19 11:27 UTC] pajoye@php.net
You have to be under an elevated user to create links (not a php restriction, but the underlying API/Function). You can try it using the console as well.
 [2009-07-19 13:35 UTC] celkaprog at gmail dot com
Soory I mistaken the eleveted word.
It's running with admin rights.(right click run as administrator.).
The problem is not solved.
I'll try to run as different user (Administrator) but I don't think that it will be good with that because this account is a member of administrators group.
 [2009-07-19 13:46 UTC] pajoye@php.net
Doh, I misread your code. Please read again the doc about symlink, the arguments in your code are in the wrong order (then the error is actually clear).
 [2009-07-19 13:55 UTC] celkaprog at gmail dot com
I logined into the administrator account.
Started apache+php.
But the problem is the same.

I opened a command prompt.
e:\foo\bar>mklink 5.jpg 1.jpg
then 5.jpg created and i can view with irfanview.
e:\anything\something>mklink "../../foo/bar/5.jpg" "../../foo/bar/1.jpg"
(without " it says invalad parameter: --)
then 6.jpg created and I cannot open it with irfanview and cannot see it's content(Total commander Lister(F3))
Interesting.
 [2009-07-19 14:01 UTC] celkaprog at gmail dot com
That was my first step to change the order.
Now I changed and still:
Warning: symlink() [function.symlink]: Could not fetch file information(error 3) in E:\\foo\bar\tree_copy.php on line 148

Here is the code what is executing:
symlink('../../images/cms/original/1.jpg','../../images/cms/original/12.jpg');

../images/cms/original/1.jpg is exists,but 12.jpg is not created.
 [2009-07-19 14:05 UTC] pajoye@php.net
Run the script in CLI as admnistrator please. But I'm 100% sure it works anyway, I just tested again on win7, 2008 and vista.
 [2009-07-19 14:27 UTC] celkaprog at gmail dot com
It's only works in this way:
chdir("../../images/cms/original");
symlink(getcwd()."\\".$file_id.".jpg",getcwd()."\\".$newfid.".jpg");
chdir("../../../foo/bar");
($file_id=1 $newfid=25, 1.jpg exitst,and in this way 25.jpg will esists and will be good to.)

And it works in this way:
chdir("../../images/cms/original");
symlink(getcwd()."\\".$file_id.".jpg",$newfid.".jpg");
chdir("../../../foo/bar");
(Here I understand that the second parameter i don't need path only the new filename?!)

And it doesn't work in this way(in the original way):
symlink("../../images/cms/original/".$fajl_id.".jpg","../../images/cms/original/$newfid.".jpg");
So i thought that it should be work in this way:
symlink("../../images/cms/original/".$fajl_id.".jpg", $newfid.".jpg");
But it doesn't work.I must chdir() to the directory and after chdir() back
 [2009-08-26 20:51 UTC] pajoye@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-09-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-09-28 20:25 UTC] pajoye@php.net
See #48746 for further comments or feedback.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 13:02:15 2014 UTC