“未能打开流:FTP服务器报告550”当使用包装访问Microsoft FTP服务上的文件时 [英] "failed to open stream: FTP server reports 550" when accessing file on Microsoft FTP Service using wrapper
问题描述
在PHP中,您有 ftp和ftps的包装,以允许您可以使用 fopen 在FTP上访问文件。
我想使用包装器将文件下载为流。
我的简化代码
//例如。 $ url =ftp:// username:password@server.com/directory-with-dash/file.mp3;
$ url ='ftp://'。 urlencode($ username)。 ':'。 urlencode($密码)。 '@'。 $服务器。 $路径。 '/'。 $文件名;
$ ctx = stream_context_create(array('ftp'=> array('resume_pos'=> 0)));
$ fin = fopen($ url,'r',false,$ ctx);
错误:
警告:fopen( ftp:/ /...@server.com/directory-with-dash/file.mp3 ):无法打开流:FTP服务器报告550 /directory-with-dash/file.mp3:系统找不到路径指定。 in /var/www/ftp.php on line 4
更多信息:
- 使用 wget 。
- 使用PHP的 220 Microsoft FTP服务和
code> 215 Windows_NT - FTP服务器可以处理被动模式使用
文件大小($ url);
导致Warning:filesize():stat失败...
-
allow_url_fopen
设置为On
- -server,
215 UNIX类型:L8
?
编辑:
我注意到 Microsof t FTP服务
在连接到FTP时不会将您置于根文件夹中,而是存放在子文件夹中:
当您使用 由FTP服务器不连接到根( 与Chrome和wget不同,PHP中的FTP包装似乎需要完整路径而不是相对路径: 适用于Chrome,wget等: ftp://用户名: password@server.com/directory-with-dash/file.mp3 对于PHP的FTP包装器: ftp:// username:password@server.com/username/directory-with-dash/file.mp3 In PHP, you have wrappers for ftp and ftps to allow you access files on an FTP using fopen. I want to use the wrapper to download a file as a stream. My simplified code: Error: 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 More Info: What might be causing the problem? Edit: I have noticed that the /username This subfolder must not be in the URL when you use ftp://username:password@server.com/username/directory-with-dash/file.mp3 // Not available in Chrome
ftp://username:password@server.com/directory-with-dash/file.mp3 // Works fine in Chrome The problem was caused by the FTP server not connecting to root ( Unlike Chrome and wget, the FTP wrapper in PHP seems to require to have the full path and not the relative path: For Chrome, wget, etc.: ftp://username:password@server.com/directory-with-dash/file.mp3 For PHP's FTP wrapper: ftp://username:password@server.com/username/directory-with-dash/file.mp3
这篇关于“未能打开流:FTP服务器报告550”当使用包装访问Microsoft FTP服务上的文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! wget $ c时,该子文件夹不得在URL中
lockquote
ftp:// username:password@server.com/username/directory-with-dash/file.mp3 //在Chrome $ b中不可用$ b ftp://用户名:password@server.com/directory-with -dash / file.mp3 //在Chrome中正常工作
我已经在PHP中尝试了这两个url - code,但我仍然得到相同的错误。(我输入错了) /
)而是连接到子文件夹( / username
)。
// eg. $url = "ftp://username:password@server.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);
220 Microsoft FTP Service
and 215 Windows_NT
filesize($url);
results in Warning: filesize(): stat failed for...
allow_url_fopen
setting is On
215 UNIX Type: L8
Microsoft FTP Service
doesn't place you in the root folder when you connect to the FTP, but in a subfolder:
wget
or a web browser:
I have tried both urls in the PHP-code, but I get the same error still. (I typed it wrong)/
) but rather to a subfolder (/username
).