这个例子将解释您如何上传ftp服务器上的文件。 ftp_put()命令允许上传在服务器上现有的文件。对于上传到ftp服务器的文件,首先你必须先登录到ftp服务器上,搜索源文件上传。定义源文件的目标路径。
然后检查基本连接。如果没有连接好,建立了连接设置使用ftp_connect($ ftp_server)。
检查FTP服务器连接的用户名。
上传文件使用ftp_put()函数,你必须确定连接ID,目标文件,源文件和FTP_Binary。
检查上传的状态,并关闭FTP连接。
良精商城网店购物系统是一套能够适合不同类型商品、超强灵活的多功能在线商店系统,三级分销 PC+移动端+微网站,为您提供了一个完整的在线开店解决方案。良精网店购物系统除了拥有一般网上商店系统所具有的所有功能,还拥有着其它网店系统没有的许多超强功能。多种独创的技术使得系统能满足各行业广大用户的各种各样的需求,是一个经过完善设计并适用于各种服务器环境的高效、全新、快速和优秀的网上购物软件解决方案。
0
立即学习“PHP免费学习笔记(深入)”;
结束该程序。
$ftp_server = "
$ftp_user_name = "
$ftp_user_pass = "
$destination_file = "C:\wamp\www\projects\public_html\upload_file\".$_FILES['image']['name'];
$sourcefile = $_FILES['image']['name'];
// 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); // line 30
// 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);
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号