php ftp_put 上传文件教程
好了我们来看看用php自带的ftp函数做的文件上传吧,上传文件我们会用到ftp_put把文件传送到服务器下面有两个上传的简单实例。
好了我们来看看用php自带的ftp函数做的文件上传吧,上传文件我们会用到ftp_put把文件传送到服务器下面有两个上传的简单实例。
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// 连接FTP服务器
$conn_id = ftp_connect($ftp_server);
//使用用户名、密码登陆
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
//上传文件
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "成功上传 $file 文件n";
} else {
echo "上传 $file 文件失败n";
}
// 关闭ftp连接
ftp_close($conn_id);
?>
// 打开将要上传的文件
$file = 'demofile.txt';
$fp = fopen($file, 'r');
// 连接FTP服务器www.111cn.cn/
$conn_id = ftp_connect($ftp_server);
//登陆FTP服务器
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// 上传文件
if(ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
echo "上传 $file 文件成功n";
} else {
echo "上传 $file 文件失败n";
}
// 关闭FTP连接
ftp_close($conn_id);
//关闭打开的上传文件
fclose($fp);
?>
转载请注明www.111cn.cn/phper/php.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software