php文件上传

来源:互联网 发布:statistica软件 编辑:程序博客网 时间:2024/05/17 03:23
1.如果是ftp服务器,可以用php自带的ftp命令上传:
<?php$file = 'somefile.txt';$remote_file = 'readme.txt';// 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);// upload a fileif (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n";} else { echo "There was a problem while uploading $file\n";}// close the connectionftp_close($conn_id);?>