Hello Guys
i'm still on the images and uploading. and since not having worked on this before i'm really struggling.
i found this script:
PHP: Upload and resize image script ( http://www.theopensurgery.com/29/php-upload-and-resize-image-script/ )
<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;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "images/" . $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."'>";
}
}
?>
I've copied it and made an images directory in my root of my server and tried running it. and i got this whole list of errors.
Warning: getimagesize(images/_DSF8681johan.jpg) [function.getimagesize]: failed to open stream: No such file or directory in D:\wamp\www\alphaVer3\upload-size.php on line 17
Warning: Division by zero in D:\wamp\www\alphaVer3\upload-size.php on line 23
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in D:\wamp\www\alphaVer3\upload-size.php on line 24
Warning: imagecreatefromjpeg(images/_DSF8681johan.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in D:\wamp\www\alphaVer3\upload-size.php on line 25
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in D:\wamp\www\alphaVer3\upload-size.php on line 26
Warning: imagejpeg(): supplied argument is not a valid Image resource in D:\wamp\www\alphaVer3\upload-size.php on line 28
Warning: getimagesize(images/_DSF8681johan.jpg) [function.getimagesize]: failed to open stream: No such file or directory in D:\wamp\www\alphaVer3\upload-size.php on line 33
Warning: Division by zero in D:\wamp\www\alphaVer3\upload-size.php on line 39
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in D:\wamp\www\alphaVer3\upload-size.php on line 40
Warning: imagecreatefromjpeg(images/_DSF8681johan.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in D:\wamp\www\alphaVer3\upload-size.php on line 41
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in D:\wamp\www\alphaVer3\upload-size.php on line 42
Warning: imagejpeg(): supplied argument is not a valid Image resource in D:\wamp\www\alphaVer3\upload-size.php on line 44
Large image: ( Broken Image )
Thumbnail: ( Broken image )
I also want to make it so it will resize the photo in 3 versions. a big photo with a 500 pixel long side, a medium photo with a 195 pixel longside and a thumbnail with a 80 pixel long side.
and then read the image filename with the path into a database.
can someone please shed some light on this for me please!
Thanks