4

I am using this plugin ng-flow for uploading .zip file and it is working properly. I need to pass dynamic values (user_id, job_id) in it for creating dynamic folders where the files get saved but this plugin uses config method to get initialize and I am not getting the way to pass dynamic value in config method

below are the codes which I have used

view part - index.html

server part - upload.php

controller part - app.js , here you will find a config function where I want to pass dynamic values to server part. In Config method I have tried to define a provider to access dynamic values but I didn't find out the way. Is there any way to access values in config (values which i want to access is in localstorageService plugin)

Hope I have explained you clearly.Any help or suggestion would be appreciated Thanks in advance

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Neeraj Rathod
  • 1,609
  • 4
  • 18
  • 25

2 Answers2

3

In you index.html file add and initialize value:

<div ng-controller="dataCtrl">
     <input ng-init="id=2374897289345" type="hidden"/>
</div>

Then open app.js and add controller with following code:

.controller('dataCtrl', ['$scope', function($scope){
    console.log('Hello');
    $scope.$on('flow::fileAdded', function (event, $flow, flowFile) {       
        $flow.opts.query = {id:$scope.id};
    });

}])

Now can access your file in post.

Sahadev
  • 1,368
  • 4
  • 18
  • 39
2

I got the solution how i can pass dynamic value dynamic values to server part.

first set flow init in your view portion

  <div flow-init = "{
                                target: '../../dummy.php',
                                permanentErrors: [404, 500, 501],
                                maxChunkRetries: 1,
                                chunkRetryInterval: 5000,
                                simultaneousUploads: 4,
                                headers: config
                  };"> 

Then set dynamic to this config variable of header in your controller

$scope.config = {
        id: localStorageService.get('userkey').id, 
        token: localStorageService.get('userkey').token
  };

(localStorageService contain my login details)

now you can access this id and token from server side by using $_SERVER

$_SERVER['HTTP_ID'];
$_SERVER['HTTP_TOKEN'];
Neeraj Rathod
  • 1,609
  • 4
  • 18
  • 25