Php web page ftp Code 2 File Upload
<? Php
$ Ftpserver =$ _ POST [ftpserver];
$ Ftpport = $ _ POST [ftpport];
$ Ftpuser = $ _ POST [ftpuser];
$ Ftppassword =$ _ POST [ftppassword];
$ Ftp = @ ftp_connect ($ ftpserver, $ ftpport );
If (! $ Ftp) {echo "connecting to the FTP server". $ ftpserver. "Port". $ ftpport. "failed"; exit ;}
$ Rs = @ ftp_login ($ ftp, $ ftpuser, $ ftppassword );
If (! $ Rs) {echo "the user name or password is incorrect. An error occurred while connecting to the FTP server"; exit ;}
$ CurDir = stripslashes ($ _ POST [curDir]);
$ Localfile = str_replace ("\", "/", stripslashes ($ _ POST [file1]);
If ($ localfile)
{
$ Filename = substr (strrchr ($ localfile, "/"), 1 );
If ($ curDir = "/")
{
$ Remotefile = $ curDir. $ filename;
} Else {
$ Remotefile = $ curDir. "/". $ filename;
}
$ Rs = ftp_put ($ ftp, $ remotefile, $ localfile, FTP_ASCII );
If ($ rs)
{
Echo "<script> alert ('file uploaded successfully'); history. back (); </script> ";
Exit;
} Else {
Echo "<script> alert ('file upload failed'); history. back (); </script> ";
Exit;
}
} Else {
Echo "<script> alert ('upload file not selected'); history. back (); </script> ";
Exit;
}
?>