Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2. header('Content-type : bitmap; charset=utf-8');
  3.  
  4. if(isset($_POST["encoded_string"])){
  5.  
  6. $encoded_string = $_POST["encoded_string"];
  7. $image_name = $_POST["image_name"];
  8.  
  9. $decoded_string = base64_decode($encoded_string);
  10.  
  11. $path = 'android_connect/images/'.$image_name;
  12.  
  13. $file = fopen($path, 'wb');
  14.  
  15. $is_written = fwrite($file, $decoded_string);
  16. fclose($file);
  17.  
  18. if($is_written > 0) {
  19.  
  20. $connection = mysqli_connect('localhost', 'root', 'rifat20081995','phpmyadmin');
  21. $query = "INSERT INTO Pictures(Name,Path) values('$image_name','$path');";
  22.  
  23. $result = mysqli_query($connection, $query) ;
  24.  
  25. if($result){
  26. echo "success";
  27. }else{
  28. echo "failed";
  29. }
  30.  
  31. mysqli_close($connection);
  32. }
  33. else
  34. {
  35. echo "file not written";
  36. }
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement