Developing PHP FTP GUI using available PHP functions
My plan is to create an FTP application with GUI front-end using php. Are there any available functions to create my PHP FTP GUI like when storing files in the FTP server? Regards.
My plan is to create an FTP application with GUI front-end using php. Are there any available functions to create my PHP FTP GUI like when storing files in the FTP server? Regards.
Hi,
An FTP application or File Transfer Protocol application is basically used for managing uploads and downloads from a given server and creating file permissions. The FTP applications can be used to upload files into a server. For that functionality, you can use php codes for file uploads and for download functionality, you can use php codes for downloading a file from a directory. For file permissions, use php codes for setting access permissions such as a public file or private file.
Some sample codes include:
Uploading php code
<?php
// Where the file is going to be placed
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
   echo "<div class='finemsg'>The file has been uploaded successfully</div>";
   include 'upload.php';
} else{
   echo "<div class='errmsg'>There was an error uploading the file, please try again!</div>";
   include 'upload.php';
}
?>
 <?php
include_once 'footer.php';
?>
Downloading php code
<?php Â
   // your file to upload Â
   $file = 'uploads/CLASS_FIVE.pdf'; Â
   header("Expires: 0"); Â
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); Â
   header("Cache-Control: no-store, no-cache, must-revalidate"); Â
   header("Cache-Control: post-check=0, pre-check=0", false); Â
   header("Pragma: no-cache"); Â
   header("Content-type: application/pdf"); Â
   // tell file size Â
   header('Content-length: '.filesize($file)); Â
   // set file name Â
   header('Content-disposition: attachment; filename='.basename($file)); Â
   readfile($file); Â
   // Exit script. So that no useless data is output-ed. Â
   exit; Â
   ?>Â
Thank you.
Â