一、upload.php 
<?php 
$Username="GTK";//用户名 
$Password="GTK";//密码 
$Server="localhost";//本机地址或主机名 
$cdir="E:/";// 
?> 
<html> 
<head> 
<title>FTP服务器 </title> 
</head> 
<body> 
<form action="ftp.php" enctype="multipart/form-data" method=post> 
<input type=hidden name=Username value= <? echo $Username; ?> > 
<input type=hidden name=Password value= <? echo $Password; ?> > 
<input type=hidden name=Server value= <? echo $Server; ?> > 
<input type=hidden name=cdir value= <? echo $cdir; ?> > <table> 
<tr> <td> <input type=file name=upfile> </td> </tr> 
<tr> <td> <input type=submit name=action value="上传"> </td> </tr> 
</table> 
</form> 
</body> 
</html> 
二、ftp.php 
<?php 
function connect() { 
global $Server,$Username,$Password; 
$conn=ftp_connect($Server);              //建立FTP连接 
@ftp_login($conn,$Username,$Password); 
return $conn; 

$result= connect(); 
if($action=="上传") 

@ftp_chdir($result, $cdir); 
$res_code=@ftp_put($result,$upfile_name,$upfile,FTP_BINARY); 
if($res_code==1) 

echo "上传成功"; 

else 

echo "上传失败"; 


ftp_quit($result);//关闭连接 ?>
老说上传失败 我的路径对吗?

解决方案 »

  1.   

    要根据返回的错误信息,楼主自己在PHP日志里面,看看是什么FTP错误.
      

  2.   

    PHP手册里面没例子吗?没做过,UP
      

  3.   

    就算你其他没错误
    我都看不到你有上传任何东西上 ftp server
    上传后的档案你都没有处理
      

  4.   

    1、你的程序只适用于 register_globals = on 的环境,请确认
    2、去掉@,看看是否有其他错误