plupload怎么设置属性,如何使用PLupload发送其他数据?

I'm using plupload to make an ajax file uploading.

Now the plupload.Uploader class has many options but none are additional data.

For Example :

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}

});

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?

解决方案

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"

}

});

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.

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's documentation is a little sparse for some of these settings.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值