原帖由 goodday 于 2009-11-8 03:28 AM 发表
$_FIlE["image"]["tmp_name"],
$_FILE["image"]["name"],
里面有什么???
echo 来看看
<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
?>
<?php
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
?>
原帖由 Super-Tomato 于 2009-11-8 04:49 AM 发表
绿色部份應該养成習慣侦测是否有错误
紅色部份兩個参數反了, 而且 remote file 没有正确路径
bool ftp_put ( resource $ftp_stream , string ...
原帖由 宅男-兜着走 于 2009-11-8 01:16 PM 发表
中shoot到够力下。 我connect 部分, 跟 chdir 部分已经测试, 是成功的。 只是 put 的部分 不懂做么会这样罢了咯。
原帖由 宅男-兜着走 于 2009-11-8 03:52 PM 发表
问你个问题, 假设我把FTP写成 class 。
现在有 5~6 个图片准备同时Upload。
每 upload 一次 ftp_connect 一次, upload 完成后就挂断。
FTPclass 就 new 多一次然后就 从新ftp_connect, 这样的写法 ...
欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) | Powered by Discuz! X2.5 |