|  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: 2022-08-05 21:11 UTC
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: smlerman at gmail dot com Assigned:
Status: Re-Opened Package: FTP related
PHP Version: 5.2.8 OS: *
Private report: No CVE-ID: None
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
 [2022-08-05 21:11 UTC]
-Package: Streams related +Package: FTP related
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 22:01:28 2024 UTC