i want to resize image. Following script working in my local server. But This coding doesn't work in php 2.6.0. please help me
Expand|Select|Wrap|Line Numbers
- <form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
- <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
- <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
- </form>
- <?php
- if(isset($_POST['submit'])){
- if (isset ($_FILES["new_image"])){
- $imagename = $_FILES["new_image"]["name"];
- $source = $_FILES["new_image"]["tmp_name"];
- $target = "images/".$imagename;
- //$prefix = 'small_';
- move_uploaded_file($source, $target);
- $imagepath = $imagename;
- $save = "images/sml_" . $imagepath; //This is the new file you saving
- $file = "images/" . $imagepath; //This is the original file
- list($width, $height) = getimagesize($file) ;
- $modwidth = 150;
- $diff = $width / $modwidth;
- $modheight = $height / $diff;
- $tn = imagecreatetruecolor($modwidth, $modheight) ;
- $image = imagecreatefromjpeg($file) ;
- imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
- imagejpeg($tn, $save, 100) ;
- $save = "images/sml_" . $imagepath; //This is the new file you saving
- $file = "images/" . $imagepath; //This is the original file
- list($width, $height) = getimagesize($file) ;
- $modwidth = 80;
- $diff = $width / $modwidth;
- $modheight = $height / $diff;
- $tn = imagecreatetruecolor($modwidth, $modheight) ;
- $image = imagecreatefromjpeg($file) ;
- imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
- imagejpeg($tn, $save, 100) ;
- echo "Large image: <img src='images/".$imagepath."'><br>";
- echo "Thumbnail: <img src='images/sml_".$imagepath."'>";
- }
- }
- ?>