Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <body>
  5.  
  6. <?php
  7.  
  8. if (isset($_POST["imgbase"]) && !empty($_POST["imgbase"])) {
  9.  
  10. // get the image data
  11. $data = $_POST['imgbase'];
  12. $bookName = $_POST['bookName'];
  13.  
  14. list($type, $data) = explode(';', $data);
  15. list(, $data) = explode(',', $data);
  16. $data = base64_decode($data);
  17.  
  18. $booksFolder = "../../../uploads/real3dflipbook/";
  19. if (!file_exists($booksFolder)) {
  20. mkdir($booksFolder, 0777, true);
  21. }
  22.  
  23. $bookFolder = "../../../uploads/real3dflipbook/".$bookName;
  24. if (!file_exists($bookFolder)) {
  25. mkdir($bookFolder, 0777, true);
  26. }
  27.  
  28.  
  29. $filename = $bookFolder."/".$_POST['pageName'].".jpg";
  30. // $thumbName = $bookFolder."/".$_POST['pageName']."_thumb.jpg";
  31.  
  32. $file = $filename;
  33.  
  34. // decode the image data and save it to file
  35. if(!file_put_contents($file, $data)){
  36. echo "failed";
  37. }else{
  38. echo "success";
  39. }
  40. // echo $file;
  41.  
  42. // $image = wp_get_image_editor( $file ); // Return an implementation that extends <tt>WP_Image_Editor</tt>
  43.  
  44. // echo("is_wp_error( $image )");
  45. // echo(is_wp_error( $image ));
  46. // if ( ! is_wp_error( $image ) ) {
  47. // $image->rotate( 90 );
  48. // $image->resize( 300, 300, true );
  49. // $image->save( $thumbName );
  50. // }
  51.  
  52. }
  53.  
  54. if (isset($_POST["deleteBook"]) && !empty($_POST["deleteBook"])) {
  55. $bookName = $_POST['deleteBook'];
  56. $dirPath = "../../../uploads/real3dflipbook/".$bookName;
  57.  
  58. if (! is_dir($dirPath)) {
  59. throw new InvalidArgumentException("$dirPath must be a directory");
  60. }
  61. if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
  62. $dirPath .= '/';
  63. }
  64. $files = glob($dirPath . '*', GLOB_MARK);
  65. foreach ($files as $file) {
  66. if (is_dir($file)) {
  67. self::deleteDir($file);
  68. } else {
  69. unlink($file);
  70. }
  71. }
  72. rmdir($dirPath);
  73. }
  74.  
  75.  
  76. ?>
  77.  
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement