上传动态发布输入变量 [英] Uploadifive dynamically posting input variables

查看:149
本文介绍了上传动态发布输入变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的问题是当函数启动的时候, MyInputVariable 是空的。

 <?php $ timestamp = time();?> 
$(
$('#file_upload')。uploadifive({
'auto':false,
'dnd':true,
' checkScript':'check-exists.php',
'formData':{$ b $'timestamp':'<?php echo $ timestamp;?>',
'token': '<?php echo md5('unique_salt'。$ timestamp);?>',
'MyNumber':$('#MyInputVariable')。val(),
},
'queueID':'queue',
'uploadScript':'upload.php',$ b $'onUploadComplete':function(file,data){console.log(data);}
});
});

必须有一个方法来激发 onUpload onUploadComplete onUploadFile 或更新 formData 我不知道该怎么做。






请注意,这是uploadiFIVE,不是uploadify。这些函数/方法有很大的不同,解决方案可能不适用于这两种方法。

解决方案

经过数小时的误导性解决方案实验这是解决方案。



在您的HTML定位标记中:

 < input id =file_uploadname =file_uploadtype =filemultiple =true> 
< a style =position:relative; top:8px; href =javascript:$('#file_upload')。uploadifive('upload')>上传文件< / a>

将锚标记更改为:

 < a style =position:relative; top:8px; href =javascript:uploadFiles();>上传文件< / a> 

完全消除初始函数调用中的formData设置,所以它看起来像这样:


$ b $

  $(function()
{
$('#file_upload')。uploadifive(
{
'auto':false,
'dnd':true,
'checkScript':'check-exists.php',
'queueID':'queue',
'uploadScript':'upload.php',$ b $'onUploadComplete':function(file,data){console.log(data);}
});
});

比添加这个函数:

<$ p $数据('uploadifive')。settings.formData =
{
' timestamp':'<?php echo $ timestamp;?>',
'token':'<?php echo md5('unique_salt'。$ timestamp);?>',
'MyNumber':$('#MyInputVariable')。val()
},
$('#file_upload')。uploadifive('upload');
}

以及其他所有需要添加的变量。
您的输入变量现在将发布在上传中。


The problem below is that when the function is initiated, of course, MyInputVariable is empty.

<?php $timestamp = time();?>
$(function () {
    $('#file_upload').uploadifive({
        'auto': false,
        'dnd': true,
        'checkScript': 'check-exists.php',
        'formData': {
            'timestamp': '<?php echo $timestamp;?>',
            'token': '<?php echo md5('unique_salt' . $timestamp);?>',
            'MyNumber': $('#MyInputVariable').val(),
        },
        'queueID': 'queue',
        'uploadScript': 'upload.php',
        'onUploadComplete': function(file, data) {console.log(data);}
    });
});

There must be a way to instigate onUpload, onUploadComplete, onUploadFile or something to update formData, but I am at a loss as to how to do that.


Please note that this is uploadiFIVE, not uploadify. The functions/methods differ significantly, and solutions will probably not apply to both.

解决方案

After many hours of experimentation with misleading solutions on the uplodifive forum, this is the solution.

In your HTML anchor tag:

<input id="file_upload" name="file_upload" type="file" multiple="true">
<a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>

Change the anchor tag to:

<a style="position: relative; top: 8px;" href="javascript:uploadFiles();">Upload Files</a>

Completely eliminate the formData setting from the initial function call so it then looks something like this:

$(function()
{
    $('#file_upload').uploadifive(
    {
        'auto'               : false,
        'dnd'                : true,
        'checkScript'        : 'check-exists.php',
        'queueID'            : 'queue',
        'uploadScript'       : 'upload.php',
        'onUploadComplete'   : function(file, data) {console.log(data);}
    });
});

Than add this function:

   function uploadFiles()
   {
      $('#file_upload').data('uploadifive').settings.formData =
      {
         'timestamp' : '<?php echo $timestamp;?>',
         'token'     : '<?php echo md5('unique_salt' . $timestamp);?>',
         'MyNumber'  : $('#MyInputVariable').val()
      },
      $('#file_upload').uploadifive('upload');
   }

And whatever other variables you need to add. Your input variables will now post on upload.

这篇关于上传动态发布输入变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆