Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- <form action="index3.php" method="post" enctype="multipart/form-data">
- <input type="file" name="filename"><br>
- <input type="submit" value="load"><br>
- </form>
- </body>
- </html>
- <?php
- class Simple {
- function load()
- {
- if(is_uploaded_file($_FILES["filename"]["tmp_name"]))
- {
- move_uploaded_file($_FILES["filename"]["tmp_name"], "img/".$_FILES["filename"]["name"]);
- } else {
- echo("Ошибка загрузки файла");
- }
- }
- function resize()
- {
- $percent = 0.5;
- $filename = $_FILES["filename"]["name"];
- list($width, $height) = getimagesize($filename);
- $new_width = $width * $percent;
- $new_height = $height * $percent;
- $image_p = imagecreatetruecolor($new_width, $new_height);
- $image = imagecreatefromjpeg($filename);
- imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
- imagejpeg($image_p, 'image2.jpg');
- }
- function show()
- {
- $filename = $_FILES["filename"]["name"];
- echo "<img src = ".$filename.">";
- echo "<img src = 'image2.jpg'>";
- }
- }
- $addclass = new Simple(123);
- $addclass->load();
- $addclass->resize();
- $addclass->show();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement