0) { $response = array( "status" => 'error', "message" => 'ERROR Return Code: '. $_FILES["img"]["error"], ); }else { $filename = $_FILES["img"]["tmp_name"]; $ran=rand(10000, 99999); $imagename=time().'_'.md5(hash('haval256,5', $imagename.$ran)); $imagepath=$path . $imagename.'.'.$extension; list($width, $height) = getimagesize( $filename ); if(move_uploaded_file($filename, $imagepath)){ $response = array( "status" => 'success', "url" => 'http://www.domain.com/User_Images/' . $imagename.'.'.$extension, "width" => $width, "height" => $height); }else{ $response = array( "status" => 'error', "message" => 'image can\'t upload'); } } }else{ $response = array( "status" => 'error', "message" => 'Un supported Format'); } } }else{ $response['status']='error'; $response['message']=$token; } }else{ $response['status']='error'; $response['message']=$empty; } }else{ $response['status']='error'; $response['message']=$isset; } echo json_encode($response); ?>