I have a websites code to edit and i have there a issue i can't solve on my own. I hope you can help me ;)
I have a HTML form with a few input fields, the form uses angularJS and on buttenpress, the data is commited via control to a php file, were a xml is made out of it. I want to add a imageupload to the process, but i'm new to angular and couldn't find anything helpful in the web.
Here are my files:
HTML:
<input type="file" file-upload multiple/>
<ul>
<li ng-repeat="file in renderData.images">{{file.name}}</li>
</ul>
controlers.js
$scope.$on("fileSelected", function (event, args) {
$scope.$apply(function () {
//add the file object to the scope's files collection
$scope.renderData.images.push(args.file);
});
});
myApp.directive('fileUpload', function () {
return {
scope: true, //create a new scope
link: function (scope, el, attrs) {
el.bind('change', function (event) {
var files = event.target.files;
//iterate files since 'multiple' may be specified on the element
for (var i = 0;i<files.length;i++) {
//emit event upward
scope.$emit("fileSelected", { file: files[i] });
}
});
}
}; });
$scope.url = 'rest/video.php';
$http.post($scope.url, { "data": $scope.renderData}).
success(function(data, status) {
$scope.status = status;
$scope.result = data;
console.log($scope.result.timeStamp);
var timestamp = $scope.result.timeStamp;
if(!$scope.result.error) {
$scope.userDataValid = true;
$scope.renderProcess = true;
if($scope.renderProcess) {
$scope.interval = $interval(function() {
$scope.getVideo(parseInt(timestamp));
}, 40000);
}
}
}).
error(function(data, status) {
$scope.data = data || "Request failed";
$scope.status = status;
});
}
video.php
function readInput() {
$validate = array();
$validate['error'] = true;
$data = file_get_contents("php://input");
$objData = json_decode($data);
// validate input
foreach($objData->data as $key => $value) {
// check images
if($key === 'images') {
foreach($value as $image) {
And here is the point I don't know how to handle the data in php and save the file to the server.
Thanks for your help! :)