Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.  
  5. </head>
  6.  
  7. <body>
  8.  
  9. <form action="index3.php" method="post" enctype="multipart/form-data">
  10. <input type="file" name="filename"><br>
  11. <input type="submit" value="load"><br>
  12. </form>
  13.  
  14.  
  15.  
  16.  
  17.  
  18. </body>
  19.  
  20.  
  21. </html>
  22.  
  23.  
  24.  
  25. <?php
  26.  
  27.  
  28.  
  29. class Simple {
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. function load()
  41. {
  42.  
  43.  
  44. if(is_uploaded_file($_FILES["filename"]["tmp_name"]))
  45. {
  46. move_uploaded_file($_FILES["filename"]["tmp_name"], "img/".$_FILES["filename"]["name"]);
  47. } else {
  48. echo("Ошибка загрузки файла");
  49. }
  50.  
  51.  
  52. }
  53.  
  54. function resize()
  55. {
  56.  
  57.  
  58.  
  59. $percent = 0.5;
  60.  
  61. $filename = $_FILES["filename"]["name"];
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. list($width, $height) = getimagesize($filename);
  70. $new_width = $width * $percent;
  71. $new_height = $height * $percent;
  72.  
  73.  
  74. $image_p = imagecreatetruecolor($new_width, $new_height);
  75. $image = imagecreatefromjpeg($filename);
  76. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  77.  
  78. imagejpeg($image_p, 'image2.jpg');
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. }
  88.  
  89.  
  90. function show()
  91. {
  92.  
  93. $filename = $_FILES["filename"]["name"];
  94.  
  95. echo "<img src = ".$filename.">";
  96.  
  97. echo "<img src = 'image2.jpg'>";
  98.  
  99.  
  100.  
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. $addclass = new Simple(123);
  115. $addclass->load();
  116. $addclass->resize();
  117. $addclass->show();
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement