PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Anuj Kumar Gupta   PHP FTP File Upload   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: PHP FTP File Upload
Connect to a FTP server and upload files
Author: By
Last change:
Date: 9 years ago
Size: 1,012 bytes
 

Contents

Class file image Download
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST)) {
   
//Define your host, username, password and directory name
   
define('FTP_HOST', 'FTP Host/IP Name');
   
define('FTP_USER', 'FTP User Name');
   
define('FTP_PASS', 'FTP Password');
   
define('DIR_NAME', 'Your Directory Name');
   
   
//Post file element
   
$arrPostFile = $_FILES['fleFile'];

   
//Include the class
   
include('class.ftpupload.php');

   
//Create the FTP object
   
$ftpObj = new FTPClient();

   
//Connect
   
$ftpObj->connect(FTP_HOST, FTP_USER, FTP_PASS);

   
//Make directory
   
$ftpObj->makeDir(DIR_NAME);
   
   
//Upload local file to new directory on server
   
$ftpObj->uploadFile($arrPostFile, DIR_NAME);

   
//Display message
   
$ftpObj->pr($ftpObj->getMessages());
}
?>

<form action="" method="post" enctype="multipart/form-data">
    <label>File:</label><input type="file" name="fleFile" id="fleFile" /><br />
    <input type="submit" value="upload" />
</form>