search
Homephp教程php手册php ftp_put 上传文件教程

php ftp_put 上传文件教程

Jun 13, 2016 am 10:09 AM
ftpphpputuploadDofunctionusTutorialdocumentofBring your own

好了我们来看看用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

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

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

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)