Advertisement
taktikhek

Untitled

Jun 30th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <form method="post" enctype="multipart/form-data">
  2. <input type="file" name="image">
  3. <input type="submit">
  4. </form>
  5. <?php
  6. if(isset($_FILES["image"])){
  7.  
  8. // makeDP
  9. $sourcePath = $_FILES["image"]["tmp_name"];
  10. $design = "frame-1.png";
  11.  
  12. $src = imagecreatefromstring(file_get_contents($sourcePath));
  13. $fg = imagecreatefrompng(__DIR__ . "/produk/$design");
  14.  
  15. list($width, $height) = getimagesize($sourcePath);
  16. $croppedFG = imagecreatetruecolor($width, $height);
  17. $background = imagecolorallocate($croppedFG, 0, 0, 0);
  18. // removing the black from the placeholder
  19. imagecolortransparent($croppedFG, $background);
  20.  
  21. imagealphablending($croppedFG, false);
  22. imagesavealpha($croppedFG, true);
  23.  
  24. imagecopyresized($croppedFG, $fg, 0, 0, 0, 0, $width, $height, 400, 400);
  25.  
  26. // Start merging
  27. $out = imagecreatetruecolor($width, $height);
  28. imagecopyresampled($out, $src, 0, 0, 0, 0, $width, $height, $width, $height);
  29. imagecopyresampled($out, $croppedFG, 0, 0, 0, 0, $width, $height, $width, $height);
  30.  
  31. ob_start();
  32. imagepng($out);
  33. $image = ob_get_clean();
  34. // makeDPend
  35.  
  36. $str="";
  37. $chars = "addzifiabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  38. $size = strlen($chars);
  39. for($i = 0;$i < 10;$i++) {
  40. $str .= $chars[rand(0,$size-1)];
  41. }
  42.  
  43. $url = $str;
  44. $loc = "order/" . $url . ".png";
  45. file_put_contents($loc, $image);
  46. echo $loc;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement