Php ftp learning (4)

Source: Internet
Author: User
ByVikramVaswaniMelonfireNovember07, below 2000 is the code list: -------------------------------------------------------------------------------- & lt ;! --Codeforindex.html beginsher By Vikram Vaswani
Melonfire
November 07,200 0
The following is a list of codes:
--------------------------------------------------------------------------------
















--------------------------------------------------------------------------------
--------------------------------------------------------------------------------








/*
--------------------------------------------------------------------------------
DISCLAIMER:

This is use-at-your-own-risk code.

It is meant only for your strative purposes and is not meant for production environments. No warranties of any kind are provided to the user.

You have been warned!

All code copyright Melonfire, 2000. Visit us at http://www.melonfire.com
--------------------------------------------------------------------------------
*/

// Function to connect to FTP server
Function connect ()
{
Global $ server, $ username, $ password;
$ Conn = ftp_connect ($ server );
Ftp_login ($ conn, $ username, $ password );
Return $ conn;
}


// Main program begins

// Check for valid form entries else print error
If (! $ Server |! $ Username |! $ Password)
{
Echo "Form data incomplete! ";
}
Else
{


// Connect
$ Result = connect ();

// Action: change directory
If ($ action = "CWD ")
{

// At initial stage $ rdir does not exist
// So assume default directory
If (! $ Rdir)
{
$ Path = ".";
}
// Get current location $ cdir and add it to requested directory $ rdir
Else
{
$ Path = $ cdir. "/". $ rdir;
}

// Change to requested directory
Ftp_chdir ($ result, $ path );

}

// Action: delete file (s)
Else if ($ action = "Delete ")
{

Ftp_chdir ($ result, $ cdir );

// Loop through selected files and delete
For ($ x = 0; $ x {
Ftp_delete ($ result, $ cdir. "/". $ dfile [$ x]);
}

}
// Action: download files
Else if ($ action = "Download ")
{

Ftp_chdir ($ result, $ cdir );

// Download selected files
// IMPORTANT: you shoshould specify a different download location here !!
For ($ x = 0; $ x {
Ftp_get ($ result, $ dfile [$ x], $ dfile [$ x], FTP_BINARY );
}

}
// Action: upload file
Else if ($ action = "Upload ")
{

Ftp_chdir ($ result, $ cdir );

// Put file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.