When i do json_encode() for uploaded file data,value of $_FILE['tmp_name'] is passed with double back slashes,and i assume thats reason why function move_uploaded_file() doesn`t work.Is there any solution for that? Here is code example
UI:
$scope.upload = function (file) {
Upload.upload({
url: '../classes/uploadPhoto.php',
data: {file: file, 'username': $scope.usernameFile}
}).then(function (resp) {
$scope.uploadedPhoto = resp.data;
});
};
PHP:
public function __construct(){
$fileObject = new stdClass();
if(isset($_FILES['file'])){
$fileObject -> name = $_FILES['file']['name'];
$fileObject -> type = $_FILES['file']['type'];
$fileObject -> tmp = $_FILES['file']['tmp_name'];
$fileObject -> error = $_FILES['file']['error'];
$fileObject -> size = $_FILES['file']['size'];
echo json_encode($fileObject);
}
}
And final part:
$target_path = 'C:/xampp/htdocs/PDP/admin/ui/img/'.$request -> imageName;
move_uploaded_file($request -> tmPath, $target_path);
Everything working fine except move_uploaded_file().