Advertisement
TrojanCoder

Image Base64 Encoder v1

Mar 15th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. // Image Base64 Encoder
  3. // Coded by Bagaz [ T1KUS90T ]
  4. // Thanks to my friends
  5. $file=$_SERVER[argv][0];
  6. $input=$_SERVER[argv][1];
  7. function base64_gambar($input) {
  8.     $info=pathinfo($input);
  9.     $ext=$info['extension'];
  10.     $anu=file_get_contents($input);
  11.     $base64=base64_encode($anu);
  12.     $res='data:image/'.$ext.';base64,'.$base64;
  13.     return $res;
  14. }
  15. function simpan($input,$hasil) {
  16.     $info=pathinfo($input);
  17.     $ext=$info['extension'];
  18.     $trim=trim($input,$ext);
  19.     $name=$trim.'txt';
  20.     $save=file_put_contents($name,$hasil);
  21.     return $save;
  22. }
  23. if($input==true) {
  24. $result=base64_gambar($input);
  25. if(simpan($input,$result)) {
  26. echo "Encoding...\n";
  27. echo "Saving...\n";
  28. echo "Success...\n";
  29. } else {
  30. echo "Encoding...\n";
  31. echo "Saving...\n";
  32. echo "Failed...\n";
  33. }
  34. } else {
  35. echo ",-----.                                
  36. |  |) /_  ,--,--. ,---.  ,--,--. ,---.  
  37. |  .-.  \' ,-.  || .-. |' ,-.  |(  .-'  
  38. |  '--' /\ '-'  |' '-' '\ '-'  |.-'  `)
  39. `------'  `--`--'.`-  /  `--`--'`----'  
  40.                 `---'                  
  41. Image Base64 Encoder v1
  42. Coded by Bagaz [ T1KUS90T ]
  43. fb.com/bacotgoblok
  44.  
  45. Usage: php ".$file." <input>
  46.  
  47. Special Thanks: My Friends and You\n";
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement