【发布时间】:2011-04-08 21:07:25
【问题描述】:
我正在尝试将图像从我的本地计算机 (PC) 上传到 FTP 服务器。作为回报,收到以下错误:
警告:ftp_put(c:/dhimage/DSC_0067.JPG) [function.ftp-put]:无法打开流:第 37 行的 /home/dxxx/public_html/ftp/test.php 中没有这样的文件或目录 无法上传
这是我的代码:
// get FTP access parameters
$host = 'ftp.xxx.com';
$user = 'abcxxx';
$pass = 'xxxxx';
$local_file = 'c:/dhimage/DSC_0067.JPG';
$ftp_file = 'DSC_0067.JPG';
// open connection
$conn = ftp_connect($host) or die ("Cannot initiate connection to host");
// send access parameters
ftp_login($conn, $user, $pass) or die("Cannot login");
// perform file upload
$upload = ftp_put($conn, $ftp_file, $local_file, FTP_BINARY);
// check upload status
// display message
if (!$upload) {
echo "Cannot upload";
} else {
echo "Upload complete";
}
// close the FTP stream
ftp_close($conn);
【问题讨论】: