PHP Implementation FTP Upload file example, _php tutorial

Source: Internet
Author: User
Tags ftp upload file

PHP Implementation FTP upload file example,


FTP upload is a common and very important application of PHP implementation skills, today to share with you the PHP implementation of FTP upload files a simple example. Hope that everyone's PHP learning can bring some help.

The main code is as follows:

function Make_directory ($ftp _stream, $dir) {//If directory already exists or can be immediately created return TRUE if  ($this->ftp_is_dir ($ftp _stream, $dir) | | @ftp_mkdir ($ftp _stream, $dir)) return true; Otherwise recursively try to make the directory if (! $this->make_directory ($ftp _stream, DirName ($dir))) return Fals  E Final step to create the directory return Ftp_mkdir ($ftp _stream, $dir);}  function Ftp_is_dir ($ftp _stream, $dir) {//Get current directory $original _directory = ftp_pwd ($ftp _stream); Test if you can change directory to $dir//suppress errors in case $dir are not a file or not a directory if (@ftp_c Hdir ($ftp _stream, $dir)) {//If it is a directory and then the directory of the original directory Ftp_    ChDir ($ftp _stream, $original _directory);  return true;  } else {return false; }} $conn = Ftp_connect ("FTP address") or Die ("Could not Connect"), Ftp_login ($conn, "Ftpname", "password");//Create Directory with FTP Make_ Directory ($conn, $path);//Using FTPSelect Enter Directory Ftp_chdir ($conn, $path);//Start uploading if (Ftp_put ($conn, $info [0][' Savename '],getcwd (). $upload->savepath. $info [0 [' Savename '],ftp_binary]) {unlink (GETCWD (). $upload->savepath. $info [0][' Savename ']);} Ftp_close ($conn);//Note the FTP permission settings on the upload side

Friends who are interested can test run or rewrite the code described in this article, and deepen understanding while allowing the code to function more fully.




http://www.bkjia.com/PHPjc/867242.html www.bkjia.com true http://www.bkjia.com/PHPjc/867242.html techarticle PHP Implementation of FTP upload file example, FTP upload is a common and very important application of PHP implementation skills, today to share with you the PHP implementation of FTP upload file simple example. Hope ...

  • 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.