2012-04-10 68 views
2

curl php APIを使用してFTPリンクにアクセスしています。特定のサイトでは、エラーコード9(アクセス拒否)が返されます。ただし、リンクはIEとFirefoxからアクセスできます。curl FTPアクセスが拒否されました

次に、私はcurlコマンドラインを実行して、同じ "アクセス不能"の結果を出しました。

> d:>\curl -v ftp://ftp1.example.com/outgoing/EHF/dbex10win_en.zip 
> * About to connect() to ftp1.example.com port 21 (#0) 
> * Trying 204.50.113.145... 
> * connected 
> * Connected to ftp1.example.com (204.50.113.145) port 21 (#0) < 220 Microsoft FTP Service 
> > USER anonymous < 331 Anonymous access allowed, send identity (e-mail name) as password. 
> > PASS [email protected] < 230-Welcome to Example FTP site! < 230 Anonymous user logged in. 
> > PWD < 257 "/" is current directory. 
> * Entry path is '/' 
> > CWD outgoing < 550 outgoing: Access is denied. 
> * Server denied you to change to the given directory 
> * Connection #0 to host ftp1.example.com left intact curl: (9) Server denied you to change to the given directory 
> > QUIT < 221 
> * Closing connection #0 

しかし、リンクはFirefoxで正常に動作します。ここでcUrlの何が問題になっていますか?おかげ

+0

ディレクトリへのフルパスを指定した場合、それは違いを作るのですか? – tcole

答えて

0

が、それは誤りがServer denied you to change to the given directory非常に明示したCURLとは何の関係も...その、単にアクセスの問題... usernamepasswordを追加

は、単に問題を解決していない...

なぜブラウザで動作します...自動ディレクトリリダイレクトはありません。どうしてカールで動かないのですか?カールはあなたがPHP経由で直接それを使用するために何ができるの関連ディレクトリに

を変更する前にログインを伴うだろう標準ftpプロセス.... fopenまたはfile_get_contentを使用することになり、あなたがアクセスしているかのように動作します...私が使用チートですブラウザを介してそれ

例お守りのような

set_time_limit(0); 
file_put_contents("out.zip", file_get_contents('ftp://204.50.113.145/outgoing/EHF/dbex10win_en.zip')); 

作品

2

カールのオプションをいじってみ--ftp法

--ftp-method [method] 
      (FTP) Control what method curl should use to reach a file on a 
      FTP(S) server. The method argument should be one of the follow‐ 
      ing alternatives: 

      multicwd 
       curl does a single CWD operation for each path part in 
       the given URL. For deep hierarchies this means very many 
       commands. This is how RFC 1738 says it should be done. 
       This is the default but the slowest behavior. 

      nocwd curl does no CWD at all. curl will do SIZE, RETR, STOR 
       etc and give a full path to the server for all these 
       commands. This is the fastest behavior. 

      singlecwd 
       curl does one CWD with the full target directory and 
       then operates on the file "normally" (like in the multi‐ 
       cwd case). This is somewhat more standards compliant 
       than 'nocwd' but without the full penalty of 'multicwd'. 
関連する問題