从FTP上传的话需要用户名密码,通过WEB上传要如何上传呢?
解决方案 »
- 请问Warning: ftp_put() [function.ftp-put]: Opening BINARY mode data connection
- Apache 配置后启动不了???
- mcrypt关于URL的加密与解密
- php怎么样一个文件上传到多个文件夹中
- smarty里面有没有一个类似与$server['php_self']当前页面路径的内置变量呢??
- 花钱找人调试一个PHP MYSQL程序
- session的问题,include别的页的问题
- 如何在LINUX环境下,用php发邮件啊.
- addslashes这个冬冬加上的下划线什么时候不需要stripslashes就可以原样显示?
- 请问,如何用PHP取得客户端的网卡号!!
- 紧急求教:如何在调用自身的页面里面保持变量的值。
- 在PHP.INI中include_path不管什么设置都不起作用
介绍
FTP 函数库可以帮助您实现客户机与服务器之间标准文件传送协议(FTP)的规范进行文件传送。FTP 的详细定义参见 http://www.faqs.org/rfcs/rfc959.html。此扩展库用来使运行的脚本对 FTP 服务器进行广泛的控制。如果你只想在一个 FTP 服务器上读写文件,考虑使用文件系统函数库中的 ftp:// wrapper,它提供了简单和更直观的接口。 需求
无需外部库文件就可以加入本扩展模块的支持。安装
In order to use FTP functions with your PHP configuration, you should add the --enable-ftp option when installing PHP 4 or --with-ftp when using PHP 3. PHP 的 Windows 版本已经内置该扩展模块的支持。您无需加载任何附加的扩展库即可使用这些函数。运行时配置
该扩展模块未定义任何设置指令。资源类型
在 FTP 模块中使用了一个资源类型,该资源类型为 FTP 的连接句柄,由函数 ftp_connect() 产生。 预定义常量
由于这些常量是由该扩展模块定义的,因此只有在该扩展模块被编译到 PHP 中,或者在运行时被动态加载后,这些常量才有效。
FTP_ASCII (integer)FTP_TEXT (integer)FTP_BINARY (integer)FTP_IMAGE (integer)FTP_TIMEOUT_SEC (integer)
参考函数 ftp_set_option()。 下列变量在 PHP 4.3.0 以后版本中被加入。
FTP_AUTOSEEK (integer)
参考函数 ftp_set_option()。 FTP_AUTORESUME (integer)
为 GET 和 PUT 请求自动决定恢复和开始的位置 (只能工作在 FTP_AUTOSEEK 打开的情况下) FTP_FAILED (integer)
异步传输失败 FTP_FINISHED (integer)
异步传输成功 FTP_MOREDATA (integer)
异步传输是活动状态的 范例
例子 1. FTP 实例<?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);
?>
目录
ftp_cdup -- 切换到当前目录的父目录
ftp_chdir -- 在 FTP 服务器上切换当前目录
ftp_chmod -- Set permissions on a file via FTP
ftp_close -- 关闭一个活动的 FTP 连接
ftp_connect -- 建立一个新的 FTP 连接
ftp_delete -- 删除 FTP 服务器上的一个文件
ftp_exec -- 请求运行一条 FTP 命令
ftp_fget -- 从 FTP 服务器上下载一个文件并保存到本地一个已经打开的文件中
ftp_fput -- 上传一个已经打开的文件到 FTP 服务器
ftp_get_option -- 返回当前 FTP 连接的各种不同的选项设置
ftp_get -- 从 FTP 服务器上下载一个文件
ftp_login -- 登入 FTP 服务器
ftp_mdtm -- 返回指定文件的最后修改时间
ftp_mkdir -- 建立新目录
ftp_nb_continue -- Continues retrieving/sending a file (non-blocking)
ftp_nb_fget -- Retrieves a file from the FTP server and writes it to an open file (non-blocking)
ftp_nb_fput -- Stores a file from an open file to the FTP server (non-blocking)
ftp_nb_get -- 重新得到一个 FTP 服务器上的文件并写入本地文件 (non-blocking)
ftp_nb_put -- 存储一个文件至 FTP 服务器 (non-blocking)
ftp_nlist -- 返回给定目录的文件列表
ftp_pasv -- 返回当前 FTP 被动模式是否打开
ftp_put -- 上传文件到 FTP 服务器
ftp_pwd -- 返回当前目录名
ftp_quit -- ftp_close() 的别名
ftp_raw -- Sends an arbitrary command to an FTP server
ftp_rawlist -- 返回指定目录下文件的详细列表
ftp_rename -- 更改 FTP 服务器上指定的文件名
ftp_rmdir -- 删除一个目录
ftp_set_option -- 设置各种 FTP 运行时间
ftp_site -- 向服务器发送站点命令
ftp_size -- 返回指定文件的大小
ftp_ssl_connect -- Opens an Secure SSL-FTP connection
ftp_systype -- 返回远程 FTP 服务器的系统类型-------------------------------------------
更详细资料请参阅 PHP手册呵呵~~
$newspicfile="../upimagegif/".$pic_name;
copy($pic,"../upimagegif/$pic_name");
$resql="insert into dynamicinfo(pic) values ($newspicfile')
$reresult=mysql_query($resql);
还要在FTP里改upimagegif这个目录的属性...就可以了...不行就EMAIL给我.
$local_file = 'local.zip';
$server_file = 'server.zip';// connect to the ftp server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);// try to download
if (ftp_get($conn_id, $local_file, $server_file, ftp_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}// close the connection
ftp_close($conn_id);?>
如果可以才可以用copy函数