|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47202 FTP fopen wrapper and # in file names
Submitted: 2009-01-23 15:22 UTC Modified: 2012-06-16 13:54 UTC
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: smlerman at gmail dot com Assigned:
Status: Re-Opened Package: Streams related
PHP Version: 5.2.8 OS: *
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-01-23 15:22 UTC] smlerman at gmail dot com
It seems that the FTP fopen wrapper truncates file names when it encounters a pound sign (#). The FTP server's log shows a request for "file".

I have tried replacing the # with %23 (the result of urlencode), but the server sees that as a request for "file%231.txt".

Reproduce code:
// Use fopen wrapper
$data = file_get_contents("

// Use ftp_* functions
$conn = ftp_connect('');
ftp_login($conn, 'username', 'password');
ftp_get($conn, 'C:\\test.txt', 'file#1.txt', FTP_BINARY);

Expected result:

Actual result:
Warning: file_get_contents( [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: FTP server reports 550 /file : The system cannot find the path specified. in...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-03 07:05 UTC]
The php_url_parse_ex function intentionally strips the # character from the filename.  I did some research and see that this was done to fix Bug #31705 (

From :
The hash ("#", ASCII 23 hex) character is reserved as a delimiter to separate the URI of an object from a fragment identifier.

This behavior is intentional.

 [2012-06-16 13:54 UTC]
-Status: Wont fix +Status: Re-Opened
 [2012-06-16 13:54 UTC]
I was able to fix the problem for the ssh2 wrapper. I assume it can be fixed for 
ftp too. See bug #59794
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 21:01:33 2015 UTC