I want to use the wrapper to download a file as a stream.
My simplified code:
// eg. $url = "ftp://username:email@example.com/directory-with-dash/file.mp3"; $url = 'ftp://' . urlencode($username) . ':' . urlencode($password) . '@' . $server . $path . '/' . $filename; $ctx = stream_context_create(array('ftp' => array('resume_pos' => 0))); $fin = fopen($url, 'r', false, $ctx);
Warning: fopen(ftp://...@server.com/directory-with-dash/file.mp3): failed to open stream: FTP server reports 550 /directory-with-dash/file.mp3: The system cannot find the path specified. in /var/www/ftp.php on line 4
- The same url works fine when used with wget on the same machine.
- Using PHP's FTP extension to download files works fine
- FTP server responds with
220 Microsoft FTP Serviceand
- FTP server can handle passive mode
Warning: filesize(): stat failed for...
- The same code worked fine against a different FTP-server,
215 UNIX Type: L8
What might be causing the problem?
I have noticed that the
Microsoft FTP Service doesn't place you in the root folder when you connect to the FTP, but in a subfolder:
This subfolder must not be in the URL when you use
wget or a web browser:
ftp://username:firstname.lastname@example.org/username/directory-with-dash/file.mp3 // Not available in Chrome ftp://username:email@example.com/directory-with-dash/file.mp3 // Works fine in Chrome
I have tried both urls in the PHP-code, but I get the same error still. (I typed it wrong)