Uploading multiple files to FTP server using jquery.MultiFile
<p>I have a problem conserning uploading multiple files to my ftp server and I am using jQuery's multifile extension.</p>

<p>This is the multifile javascript code on page with the upload form (file_upload.php):</p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(function(){ // wait for document to load 
     $('.remove').MultiFile({ 
        STRING: {
         remove: '&lt;img src="images/upload-remove.png" height="16" width="16" alt="x"/&gt;',
         denied:'You can't choose file $ext .\nTry again...',
         file:'$file',
         selected:'Chosen file: $file',
         duplicate:'This file is already chosen:\n$file'
        }
     }); 
    });
&lt;/script&gt;
</code></pre>

<p>And this is the HTML form (file_upload.php):</p>

<pre><code>&lt;form name="uploader" action="file_upload2.php" method="post" enctype="multipart/form-data"&gt;
    &lt;fieldset&gt;
        &lt;label for="file"&gt;Upload file:&lt;/label&gt;
        &lt;br /&gt;
            &lt;input type="file" class="multi, remove" name="file[]" value="Upload file" /&gt;
            &lt;input type="submit" value="submit"/&gt;
    &lt;/fieldset&gt;
&lt;/form&gt;
</code></pre>

<p>The PHP part is where I don't get it. I tried to do it with this code (file_upload2.php):</p>

<pre><code>&lt;?php
if(isset($_POST['submit']))
{
    $ftp_config['server'] = 'ftpserver.org'; //ftp host
    $ftp_config['username'] = 'ftp_username'; // ftp username
    $ftp_config['password'] = 'ftp_password'; // ftp user password
    $ftp_config['web_root'] = 'public_html'; //foldername from user home dir.

    $fileElementName = 'file[]'; //file field name

    $conn_id = ftp_connect($ftp_config['server']);
    $ftp_login = ftp_login($conn_id,$ftp_config['username'],$ftp_config['password']);

    if(!ftp_put($conn_id,$ftp_config['web_root'].'/'.$_FILES[$fileElementName]['name'],$_FILES[$fileElementName]['tmp_name'],FTP_BINARY)){
        $result = " Error occurred.  ";
    }else{
        $result = " File has been uploaded. ";
    }
    echo $result;
}
?&gt;
</code></pre>
