LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

How exactly to use setData() #111

Closed jeebsion closed 9 years ago

jeebsion commented 9 years ago

Everything went well as per example until I realize that I need to pass additional variable to upload.php. Any advice, please?

LPology commented 9 years ago

The most common way is to use it in the onSubmit() callback function:

onSubmit: function() {
    var self = this;

    self.setData({
        someItem: 'value of first item',
        anotherItem: 'value of second item'
    });
});

You'll then be able to access the data on the server side as you normally would a file input. You mentioned PHP:

$someItem = $_REQUEST['someItem']; // 'value of first item'
$anotherItem = $_REQUEST['anotherItem']; // 'value of second item'