Automate FTP file on server with a simple php upload script

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

Hi Techy,

How to make a simple php upload script that would automatically save, send and replace the recently edited file on my FTP server everytime it detects a change on the .php file ?

Thanks in advance.

SHARE
Best Answer by Shifflett Laurel
Answered By 265 points N/A #153867

Automate FTP file on server with a simple php upload script

qa-featured

Hey there Charles, 

PHP is a very useful and easy language, and I believe that it wont be too long for you to learn the basics. I am giving you here an "upload" script in php and this will help you with your automation project. Just make sure that you got all the tools you need when starting and working all the way your project to lessen delays. Hope this help you solve your problem.

For more information about PHP go to : W3 School's Website

Waall Mike

Best Answer
Best Answer
Answered By 0 points N/A #153868

Automate FTP file on server with a simple php upload script

qa-featured

Hello!!

I am very glad to receive your interesting problem. And I am giving some important suggestions.

This is an exclusive script for uploading file into your server.

Here a function isset is used to locate and upload the file from a specific directory. I am giving just the code for uploading the file type of jpeg and gif.  

<?PHP

$upload_dir ="images";
 
if ( isset($_FILES['fupload'])) {
    $file_name = $_FILES['fupload']['name'];
    $file_type = $_FILES['fupload']['type'];
    
    if ($file_type =="image/jpeg" or $file_type=="image/gif")
    {
        copy($_FILES['fupload']['tmp_name'], "$upload_dir/$file_name") or die("Couldn't copy");
        print "<img src="$upload_dir/$file_name"<p>";
    }
}

?>

 

Regards

Shifflett Laurel

 

Login/Register to Answer

Related Questions