|  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.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: Streams related
PHP Version: 5.2.8 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
48 - 2 = ?
Subscribe to this entry?

 [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-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 03:03:34 2021 UTC