如何使用PLupload发送其他数据? [英] How to send additional data using PLupload?

查看:182
本文介绍了如何使用PLupload发送其他数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 plupload 上传ajax文件. 现在,plupload.Uploader类具有许多选项,但没有其他数据.

I'm using plupload to make an ajax file uploading. Now the plupload.Uploader class has many options but none are additional data.

例如:

var uploader = new plupload.Uploader({
    runtimes : 'gears,html5,flash,silverlight,browserplus',
    browse_button : 'pickfiles',
    container : 'contact_container',
    max_file_size : '10mb',
    url : 'upload.php',
    flash_swf_url : '/plupload/js/plupload.flash.swf',
    silverlight_xap_url : '/plupload/js/plupload.silverlight.xap',
    filters : [
        {title : "Image files", extensions : "jpg,gif,png"},
        {title : "Zip files", extensions : "zip"}
    ],
    resize : {width : 320, height : 240, quality : 90}
});

我要达到的目标是我的服务器上有一个文件夹,所有上传的文件都在其中 正在保存. 我在该文件夹内创建了一个文件夹,给在此文件夹中上传文件的每个用户创建一个子文件夹. 如何将类似用户ID的数据添加到plupload.Uploader实例? 或者,如果我将表单包装在容器div中,是否可以在$ _REQUEST中看到它? 还是我可以通过其他方式实现这一目标?

What i'm trying to achive is i have a folder in my server where all the uploads are being saved. I neeed inside the folder to create a sub-folder to each user that have uploaded files there. How can i add data like id of the user to the instance of plupload.Uploader? Or if i'll wrap a form inside the container div, will i be able to see it in the $_REQUEST? Or is there some other way i can achive this?

推荐答案

您是否尝试过使用multipart_params的设置?像这样向您的plupload.Uploader添加一个附加选项:

Have you tried using the setting for multipart_params? Add an additional option to your plupload.Uploader like so:

var uploader = new plupload.Uploader({
    runtimes : 'gears,html5,flash,silverlight,browserplus',
    browse_button : 'pickfiles',
    container : 'contact_container',
    max_file_size : '10mb',
    url : 'upload.php',
    flash_swf_url : '/plupload/js/plupload.flash.swf',
    silverlight_xap_url : '/plupload/js/plupload.silverlight.xap',
    filters : [
        {title : "Image files", extensions : "jpg,gif,png"},
        {title : "Zip files", extensions : "zip"}
    ],
    resize : {width : 320, height : 240, quality : 90},
    multipart_params : {
        "name1" : "value1",
        "name2" : "value2"
    }
});

然后,您将需要处理用于处理上载的文件中的值(默认情况下为upload.php).我认为这些值是由$_POST捕获的,但是可以确保使用$_REQUEST.

You will then need to process the values in the file that handles the upload (upload.php by default). I think the values are captured by $_POST but you can use $_REQUEST just to be sure.

我使用jQuery即时分配值,因此可以代替"name1" : $("#name1").val(),来使用"name1" : $("#name1").val(),,其中#name1可能是页面其他位置的输入.

I've used jQuery to assign values on the fly, so instead of "name1" : "value1" you can use something like "name1" : $("#name1").val(), where #name1 might be an input elsewhere on the page.

Plupload的文档对于其中的某些设置有些稀疏.

Plupload's documentation is a little sparse for some of these settings.

这篇关于如何使用PLupload发送其他数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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