1

I'm trying to upload files to FTP through PHP, and it works... sort of. Please have a look at my code;

        $filename = $_FILES['files']['name'];
            $host = "ftp.mydomain.com";
            $username = "myusername";
            $password = "mypassword";
            $local_file = 'upload/'.$filename;
            $remote_file = $filename;

            $con = ftp_connect($host, 21) or die("Couldnt connect");
            $log = ftp_login($con, $username, $password) or die("Wrong username or password.");

            ftp_pasv($con, true);

            $upload = ftp_put($con, $remote_file, $local_file, FTP_BINARY);
            if($upload) echo 'Error.';
            ftp_close($con);

            echo 'Success';
            exit;

This script actually work, but just with ONE file. If I'm uploading multiple files through my form, it will just upload one file. I want all of the files from my form to be uploaded. How can I do that?

zorensen
  • 334
  • 4
  • 19