0

This is my uploadifive setup:

Inside body:

<div id="file_rows_wrapper">
   <div class="file_row">
      <input class="file_upload" name="file_upload" type="file" multiple="false">
   </div>
</div>
<a href="#" onclick="add_file();">Add Another File</a>

While this is the javascript part:

    $(function() { 
        uploadify();             
    }); 

    function uploadify() {           
        <?php $timestamp = time();?>

        $('.file_upload').uploadifive({
            'auto'             : true,
            'checkScript'      : '/files/check_exists',
            'formData'         : {
                                   'timestamp' : '<?php echo $timestamp;?>',
                                   'token'     : '<?php echo md5('hiall' . $timestamp);?>'
                                 },
            'queueID'          : 'queue',
            'uploadScript'     : '/files/upload_file',
            'multi'       : false,
            'buttonText'  : 'Upload File',

        }); 
    };  

function add_file()
{
            var file = $('.file_row:first').clone();
            file.css('margin-top', '20px');

            file.fadeIn().appendTo($('#file_rows_wrapper'));

            uploadify();
}

All works as expected. The "file_row" div is being cloned but when clicking on the "Add Another File" and choosing the local file, nothing happens. There is no upload. If I maually copy the "file_row" div more times then the upload works fine, even more uploads at once. What am I doing wrong?

4

1 回答 1

0

我认为您需要在文件输入中使用唯一 id 才能在一页上有多个实例。

于 2016-03-04T21:23:53.827 回答