title: How to upload file from javascript to php server?
body: <p>How to upload image or other file from javascript to php server ???
  i am working on php api how to send and receive 
  please help me
  i am getting josn data using </p>
  
  <pre><code>$login = file_get_contents('php://input');
  </code></pre>
  
  <p>i want to upload image using js and receive using php and upload to server disk
  Here is my login.php file</p>
  
  <pre><code>  &lt;?php
  session_start();
  //server accpet response in forllowing format 
  //{"username":"administrator","password":"administrator","remind":"on"}
  // iuncluding function file
  require_once "../includes/system.php";
      if(isset($_COOKIE['COOKIE_KEEP_ME_NAME1shpingcart'])){
              $_SESSION['login_usershoping'] =  $_COOKIE['COOKIE_KEEP_ME_NAME1shpingcart'];
          }   
     if(isset($_SESSION['login_usershoping'])){
      $success['alreadylogin'] = "true";
      echo $successlogin = malik_encode($success );
      die();
  }
  // get value
  $login = file_get_contents('php://input');
      if(empty($login)){
          $error['error'] = "Username &amp; password never be empty";
          echo $errorlogin = malik_encode($error );
          die();
      }
  //decode and convert into assos array by using custom function
  $login_decode = malik_decode($login,true);
      $username =  $login_decode['username'];
      $password =  $login_decode['password'];
      $remind = $login_decode['remind'];
  
      $db = malik_database_connection();
      $connected = null;   
      $username = $db-&gt;quote($username);
          $select = $db-&gt;query("SELECT * FROM users WHERE username=$username");
          if($select-&gt;rowCount() &gt; 0){
              $user = $select-&gt;fetch();
              $ban = $user['ban'];
                if($ban === 'yes'){
                   $error['error'] = "Your account is banned by our admistrator";
                   echo $banerror = malik_encode($error );
                }         
              if (password_verify($password, $user["password"])){
                  if(isset($remind) &amp;&amp; $remind === 'on'){
                  //generate for storing cookies
                  setcookie('COOKIE_KEEP_ME_NAME1shpingcart',$user['salts'] ,time() + (86400 * 30 * 12), '/',false,true);
                  //generate for storing cookies
                  setcookie('COOKIE_KEEP_ME_NAME2',malik_ramdomstring_generator(60) ,time() + (86400 * 30 * 12), '/',false,true);
                  //generate for storing cookies
                  setcookie('COOKIE_KEEP_ME_NAME3',malik_ramdomstring_generator(50) ,time() + (86400 * 30 * 12), '/',false,true);
                  }   
                  $se= $_SESSION['login_usershoping'] =  $user['salts'];
                   $success['success'] = "true";
                   echo $loginsuccess = malik_encode($success );
                  exit();
  
              }else {
                  $connected = false;
              }
              }else{
              $connected = false;
          }
             if ($connected === false): 
             $error['error'] = "Username and password wrong";
              echo $loginerror = malik_encode($error );
           $connected = null; 
         endif; 
  </code></pre>