I am very new to Angular so forgive me first of all :)

I am coming from a php MVC Codeigniter. But I am unable to insert username 
and file in to Database(Mysql) using Codeigniter Service,but my file is 
uploading
here is my factory code:
*Controller.js Code*
app.factory("services", ['$http', function($http) {
var url = 'http://localhost/register/uploadfile 
<http://localhost:78/iblood/register/uploadfile>';
 var fd = new FormData();
 for ( var i = 0; i < files.length; i++)
 {
  fd.append("file", files[i]);
 }
// var data1={id:id};
*  fd.append("username", username);*
  $http.post(url, fd, {
  
   withCredentials : false,
  
   headers : {
    'Content-Type' : undefined
   },
 transformRequest : angular.identity
 });
}
*Php Code*
function uploadfile(){
$target_dir = "upload/avatar/";
$filename = "koti"."-"."raju"."-".basename($_FILES["file"]["name"]);
$target_file = $target_dir . $filename;
move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
 
        $json_register= file_get_contents('php://input');
$registerdata = json_decode($json_register,true);
$post_username = $registerdata['username']; 
 $arr = array(
'profilepic'=>$filename  
); 
$check =  $this->register_model->edit($arr,$post_donor_id); 
    if($check > 0) 
{
$msg = "Data Updated Successfully";
header('Content-type: application/json');
$data = array('status' => "0",'desc' => $msg);
echo json_encode($data);
}

}

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to