Sending form data with angular-file-upload

I'm using nervgh's angular-file-upload and I'd like to send formData based on user inputs. I can request different fields from the formData but not when they are pushed onBeforeUploadItem.

I have the uploader set up like so:

var uploader = $scope.uploader = new FileUploader({
        url: 'upload.php',
        formData: [{
         param1: 'value1',
         param2: 'value2',
         param3: 'value3'

uploader.onBeforeUploadItem = function(item) {
        item.formData.push({test: 'TEST'});'onBeforeUploadItem', item);

In my upload.php I get value1 for $_REQUEST['param1'] but I get no data when I do the same with test, $_REQUEST['test'].

$myValue1 = $_REQUEST['param1']; <-- equals value1
$test = $_REQUEST['test']; <-- empty

Any idea how I can get an added field from my upload.php? Thanks


Instead of trying this way, you may try to upload your files via formData using multipart/form-data. An example is given below:

    <form action="yoururl" method="post" ng-submit="yoursubmitaction" enctype="multipart/form-data">
       <input type="text" name="text1" />
       <input type="text" name="text2" />
       <input type="file" name="Attachment"/>

Need Your Help