编程语言
首页 > 编程语言> > javascript-存在多个uploadify实例时未传递scriptData

javascript-存在多个uploadify实例时未传递scriptData

作者:互联网

我的表单中有两个uploadify实例.您将在下面找到定义.

还有两个按钮触发上传.图像按钮是唯一与问题相关的按钮:

$( "#btnimageupload" ).button().click(function()
{
 $('#picbrowse').uploadifySettings( 'scriptData', ({ 'isSelected': $( '#selectImage' ).val() }));
 $('#picbrowse').uploadifyUpload();
});

现在,这是问题所在:

当我单击btnimageupload按钮时,图像不会上传.进度条转到100并停止.没有错误,javascript或其他.

但是,当我禁用vdobrowse文件输入框及其相应的脚本时,一切正常.图像已上传,数据正在传输.

这是棘手的部分…如果我没有在btnimageupload点击处理程序上传递scriptData,即使页面上有vdobrowse文件输入框,图像也会上传.

因此,在我看来,当页面上有一个以上的ifyifyify实例时,scriptData正在破坏uploadify.

有人知道我该如何解决?

Uploadify定义

$('#picbrowse').uploadify(
{
 uploader  : 'script/uplodify/uploadify.swf',
 script    : '../../dopost.php',
 cancelImg : 'script/uplodify/cancel.png',
 folder    : '/images',
 queueID   : 'picqueue',
 auto      : false,
 multi     : true,
 fileDesc    : 'Image Files',
 fileExt     : '*.gif;*.jpg;',
 queueSizeLimit: 5,
 scriptData:
 ({
  'action': 'upload_image',
 }),
 onComplete: function( event, queueID, fileObj, response, data )
 {
  console.log( reponse)
 }
});

.

$('#vdobrowse').uploadify(
{
 uploader  : 'script/uplodify/uploadify.swf',
 script    : '../../dopost.php',
 cancelImg : 'script/uplodify/cancel.png',
 folder    : '/video',
 queueID   : 'vdoqueue',
 auto      : false,
 multi     : true,
 fileDesc    : 'Video Files',
 fileExt     : '*.avi;*.mpg;*.mov;*.mp4;*.mpeg;*.flv;*.mkv;*.wmv',
 queueSizeLimit: 5,
 scriptData:
 {
  action: 'upload_video'
 },
 onComplete: function( event, queueID, fileObj, response, data )
 {
  console.log( response );
 }

});

解决方法:

The plugin appears to be putting the
options into global space, which is
why when you are using two or more
uploadify’s with scriptData it is
picking up the last stored value in
scriptData.

I see running two uploadify’s on one
page a pointless exercise and as such
I never test the functionality with
multiple uploadify’s.
uploadifySettings works perfectly with
one uploadify. Multiple uploadify’s
are the demo page to demonstrate the
different setups possible.

That said, it is still obviously a
problem for users and we will need to
fix it for those that wish to use
multiple uploadify’s on the same page.

Forum

我建议使用swfUpload.我在我的项目中使用了它,并使用了多个实例进行了测试,并且效果很好.因此swfUpload易于理解,并且api看起来像uploadify api.

标签:upload,uploadify,javascript,jquery
来源: https://codeday.me/bug/20191208/2094935.html