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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)
