使用多个uploadify按钮

时间:2013-10-12 05:13:23

标签: php jquery ajax uploadify

我有一个包含4个uploadify按钮的页面。说到4 uploadify按钮,我放了4个这样的脚本:

    $(function() {
         $('#file_upload').uploadify({
            'formData'     : {
          'PHPSESSID': '<?=session_id()?>',
              'timestamp' : '<?php echo $timestamp;?>',
              'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
            },
            'swf'      : 'uploadify.swf',
            'uploader' : 'uploadify.php?id=<? echo $resID; ?>&state=<? echo strtolower($negeri); ?>',
            'onQueueComplete': function() { 
                   setTimeout(function(){location.reload(true);},100)
                   }

         });
$('#file_upload1').uploadify({
                'formData'     : {
              'PHPSESSID': '<?=session_id()?>',
                  'timestamp' : '<?php echo $timestamp;?>',
                  'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                },
                'swf'      : 'uploadify.swf',
                'uploader' : 'uploadify1.php?id=<? echo $resID; ?>&state=<? echo strtolower($negeri); ?>',
                'onQueueComplete': function() { 
                       setTimeout(function(){location.reload(true);},100)
                       }

             });
$('#file_upload2').uploadify({
                'formData'     : {
              'PHPSESSID': '<?=session_id()?>',
                  'timestamp' : '<?php echo $timestamp;?>',
                  'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                },
                'swf'      : 'uploadify.swf',
                'uploader' : 'uploadify2.php?id=<? echo $resID; ?>&state=<? echo strtolower($negeri); ?>',
                'onQueueComplete': function() { 
                       setTimeout(function(){location.reload(true);},100)
                       }

             });
$('#file_upload3').uploadify({
                'formData'     : {
                  'PHPSESSID': '<?=session_id()?>',
                  'timestamp' : '<?php echo $timestamp;?>',
                  'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                },
                'swf'      : 'uploadify.swf',
                'uploader' : 'uploadify3.php?id=<? echo $resID; ?>&state=<? echo strtolower($negeri); ?>',
                'onQueueComplete': function() { 
                       setTimeout(function(){location.reload(true);},100)
                       }

             });
        });

问题它会破坏我的所有会话。但是当我只放一个脚本时。它不会破坏我的会话。

有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

你可以像这样使用

$('#file_upload,#file_upload1, #file_upload2,#file_upload3').uploadify({
                    'formData'     : {
                  'PHPSESSID': '<?=session_id()?>',
                      'timestamp' : '<?php echo $timestamp;?>',
                      'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                    },
                    'swf'      : 'uploadify.swf',
                    'uploader' : 'uploadify2.php?id=<? echo $resID; ?>&state=<? echo strtolower($negeri); ?>',
                    'onQueueComplete': function() { 
                           setTimeout(function(){location.reload(true);},100)
                           }

                 });