一、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);//关闭连接 ?>
老说上传失败 我的路径对吗?
<?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);//关闭连接 ?>
老说上传失败 我的路径对吗?
我都看不到你有上传任何东西上 ftp server
上传后的档案你都没有处理
2、去掉@,看看是否有其他错误