I have found a lot or resources on how to pass a hidden input field value to an angularjs script, but not if that value is being read from a php session.
This is my html code:
<div ng-controller="ImgCtrl">
<input type="hidden" ng-model="uid" value="<?=$_SESSION["uid"];?>" >
<input type="file" ng-file-select="onFileSelect($files)" >
<br/>
<span>{{ message }}</span>
</div>
I have also tried it as this:
<input type="hidden" ng-model="uid" value="{{<?=$_SESSION["uid"];?>}}" >
EDIT The angularjs code that will handle it is:
var ImgCtrl = [ '$scope', '$upload', function($scope, $upload) {
$scope.onFileSelect = function($files) {
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
$scope.upload = $upload.upload({
url: 'image_upload.php',
method: 'POST',
data: {
'uid': $scope.uid
},
file: file
}).success(function(data, status, headers, config) {
$scope.message = data;
}).error(function(data, status) {
alert(data);
});
}
};
}];
Which was one of the answers I found, but I can not seem to find how to read a php session variable in angularjs.
Anyone have an idea?
Thanks!