本文介绍了“未能打开流:FTP服务器报告550”当使用包装访问Microsoft FTP服务上的文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,您有,以允许您可以使用在FTP上访问文件。



我想使用包装器将文件下载为流。

我的简化代码

  code> 215 Windows_NT   
  • FTP服务器可以处理被动模式使用文件大小($ url); 导致 Warning:filesize():stat失败...

  • allow_url_fopen 设置为 On

  • -server, 215 UNIX类型:L8





  • 编辑:

    我注意到 Microsof t FTP服务在连接到FTP时不会将您置于根文件夹中,而是存放在子文件夹中:

    当您使用 wget
    lockquote
    //在Chrome $ b中不可用$ b //在Chrome中正常工作

    (我输入错了)

    解决方案

    由FTP服务器不连接到根( / )而是连接到子文件夹( / username )。



    与Chrome和wget不同,PHP中的FTP包装似乎需要完整路径而不是相对路径:

    适用于Chrome,wget等:

    对于PHP的FTP包装器:


    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:

    // 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);
    

    Error:

    More Info:

    • 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 Service and 215 Windows_NT
    • FTP server can handle passive mode
    • Using filesize($url); results in Warning: filesize(): stat failed for...
    • allow_url_fopen setting is On
    • The same code worked fine against a different FTP-server, 215 UNIX Type: L8

    What might be causing the problem?

    Edit:

    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:

    (I typed it wrong)

    解决方案

    The problem was caused by the FTP server not connecting to root (/) but rather to a subfolder (/username).

    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.:

    For PHP's FTP wrapper:

    这篇关于“未能打开流:FTP服务器报告550”当使用包装访问Microsoft FTP服务上的文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-29 06:11