Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [Script] How to Upload files to FTP Using PHP

    Hi all,

    It seems amazing seeing PHP managing FTP, below is a script i coded for uploading files to FTP and its fantastic!
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Simple FTP Upload Script using PHP by 2netlodge</title>
    </head>
    
    <body>
    <?php
    if(isset($_POST['ftp']))
     	{
    		$ftp = $_POST['ftp'];
    		$username = $_POST['username'];
    		$pwd = $_POST['pwd'];
    		$filename = $_FILES['file']['name'];
    		$tmp = $_FILES['file']['tmp_name'];
    		$d = $_POST['des'];
    		
    		$connect = ftp_connect($ftp)or die("Unable to connect to host");
    		ftp_login($connect,$username,$pwd)or die("Authorization Failed");
    		echo "Connected!<br/>";				
    		
    		if(!$filename)
    			{
    				echo"Please select a file";
    			}
    		else
    			{
    				ftp_put($connect,$d.'/'.$filename,$tmp,FTP_ASCII)or die("Unable to upload");
    						echo"File successfully uploaded to FTP";
    			}
    	}
    ?>
    <form action="" method="post" enctype="multipart/form-data">
    <input type="text" name="ftp" placeholder="FTP link"/><br/>
    <input type="text" name="username" placeholder="Username"/><br/>
    <input type="password" name="pwd" placeholder="Password"/><br/>
    <input type="file" name="file" /><br/>
    <input type="text" name="des" placeholder="Destination"  /><br/>
    <br/><input type="submit" value="Upload"/></form>
    <footer>Share and get more scripts and codes like this, visit <a href="http://2netlodge.com">http://2netlodge.com</a> Forum</footer>
    </body>
    </html>
    Hope it helps!

  2. #2
    New to the CF scene
    Join Date
    Aug 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi.. unfortunately I am unable to get a good result from this code.

    Can you have a look why?

    Tested via Tryit Editor v3.0

    -code-jpg

  3. #3
    Regular Coder
    Join Date
    Oct 2015
    Posts
    370
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Don't use it, it was out of date, insecure and pointless when it was written - 3 years ago. Just search for a recent file upload script or use standard ftp software e.g. filezilla.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •