Developing PHP FTP GUI using available PHP functions

Asked By 10 points N/A Posted on -
qa-featured

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.

SHARE
Answered By 0 points N/A #151988

Developing PHP FTP GUI using available PHP functions

qa-featured

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.

 

Login/Register to Answer

Related Questions