2014-01-10 220 views
1

在PHP中,您有wrappers for ftp and ftps允許您使用fopen訪問FTP上的文件。使用包裝器訪問Microsoft FTP服務上的文件時,「無法打開流:FTP服務器報告550」

我想使用包裝下載文件作爲流。

我的簡化代碼:

// eg. $url = "ftp://username:[email protected]/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://[email protected]/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

更多信息:與0123一起使用時

  • 相同的URL工作正常在同一臺機器上。
  • 使用PHP的FTP extension下載文件工作正常
  • FTP服務器220 Microsoft FTP Service響應和215 Windows_NT
  • FTP服務器可以在Warning: filesize(): stat failed for...
  • allow_url_fopen設定處理被動模式
  • 使用filesize($url);結果是On
  • 同代碼對不同的FTP服務器工作正常,215 UNIX Type: L8

什麼可能導致此問題?

編輯:

我已經注意到,當您連接到FTP的Microsoft FTP Service不把你的根文件夾,但在子文件夾:

/username

該子文件夾不得在該URL當您使用wget或Web瀏覽器:

ftp://username:[email protected]/username/directory-with-dash/file.mp3 // Not available in Chrome ftp://username:[email protected]/directory-with-dash/file.mp3 // Works fine in Chrome

我公頃我已經在PHP代碼中嘗試了這兩個url,但我仍然得到相同的錯誤。 (我輸入錯了)

+0

我成功地爲不同的FTP服務器的連接。這看起來與'Microsoft FTP服務'有些不協調。編輯。 – ANisus

+0

我假設_「系統找不到指定的路徑」_是由服務器返回的。您可以訪問服務器日誌以查看此請求轉換爲什麼本地路徑? – CodeCaster

+0

@CodeCaster是的,它似乎來自FTP服務器。我無法訪問FTP服務器日誌。也許我可以要求他們。 – ANisus

回答