将输入字段添加到Uploadifive / Uploadify - php

我一直在寻找有关如何添加输入字段并将额外的变量传递到uploadifive.php文件的答案。但是,我无法发布任何已发布的解决方案,并且在大多数情况下,我确实发现的那些解决方案从未被列为有效或解决方案。

有人可以告诉我如何将输入字段的内容传递给uploadifive.php文件吗?

这是我的HTML

<input type="text" name="student" id="student" placeholder="Your Student ID" value="" />
<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>

这是javascript

<?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadifive({
            'auto'     : false,
            'method'   : 'post',
            'formData' : {
                'timestamp' : '<?php echo $timestamp;?>',
                'token'     : '<?php echo md5('unique_salt' . $timestamp);?>',
                'student'   : $('#student').val()
                      },
                'queueID'          : 'queue',
                'uploadScript'     : 'uploadifive.php',
                'onUploadComplete' : function(file, data) { console.log(data); }
            });
        });

这是我尝试在php文件中使用它的方式,但是没有传递任何值

$_POST['student']

如果有人能告诉我我做错了什么,我们如何使它正常工作,我将非常感激。

谢谢,
加里

参考方案

我们需要阅读的输入仍然存在

<input type="text" name="student" id="student" placeholder="Your Student ID" value="" />

使用此js作为指导(我仅包含对示例重要的选项):

$('#my_file').uploadifive ({
    'formData': {
        //Some data we already know
        'timestamp' : "1400137111",
        'token'     : "a9b7ba70783b617e9998dc4dd82eb3c5"
     },

     //This will be executed before the upload process starts, so here's where
     //you will get the values in your form and will add them to formData.
     'onUpload': function(filesToUpload) {
         //Most of jQuery plugins, and luckily this one, uses the function jQuery.data
         //to save the settings we use on plugin's initialization.
         //In this case we can find those settings like this:
         var settings = $(this).data('uploadifive').settings;

         //Now we need to edit formData and add our input's value
         settings.formData.student = $('#student').val();

         //formData has the value readed from the input, so we store 
         //it again using jQuery.data
         $(this).data('uploadifive').settings = settings;

         //After this the plugin will perform the upload, reading the settings with
         //jQuery.data and our input's value will be present
     },

});

PHP strtotime困境 - php

有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00�…

PHP-全局变量的性能和内存问题 - php

假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP-正则表达式删除引号并添加大括号? - php

好吧,我不愿承认这一点,但是我对REGEX感到很困难,我永远找不到关于如何设置表达式的不错的教程。所以说我有这样的事情context['something'] 我想将所有事件更改为context[something] 那我有' . $var . ' 我想将所有事件更改为{var} 这是当前的概念,但是我在正则表达式部分…

PHP Laravel从另一个驱动器读取文件 - php

我目前正在学习Laravel。我想知道是否有一种方法可以在Laravel中使用Storage::从另一个硬盘访问文件(使用Windows)。例如,我在驱动器C:上安装了带有Laravel的Xampp,但是我想访问网站目录之外的E:上的文件。我试过使用Storage::files('E:')和File::files('E:…