proctk Posted July 16, 2007 Share Posted July 16, 2007 Hi the below code is supposed to upload images to a folder called user_images. Its not working its giving me the following error messages any ideas whats wrong thank you Warning: Division by zero in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/album.php on line 92 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/album.php on line 93 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/album.php on line 97 Warning: imagejpeg(): supplied argument is not a valid Image resource in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/album.php on line 102 Warning: imagedestroy(): supplied argument is not a valid Image resource in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/album.php on line 104 Warning: imagedestroy(): supplied argument is not a valid Image resource in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/album.php on line 105 // upload Images if(isset($_POST['upLoadImages'])){ foreach ($_FILES['file']['tmp_name'] as $i => $val) : // This is the temporary file created by PHP $uploadedfile = $_FILES['file']['tmp_name'][i]; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height)=getimagesize($uploadedfile); // For our purposes, I have resized the image to be // 600 pixels wide, and maintain the original aspect // ratio. This prevents the image from being "stretched" // or "squashed". If you prefer some max width other than // 600, simply change the $newwidth variable $newwidth=600; $newheight=($height/$width)*600; $tmp=imagecreatetruecolor($newwidth,$newheight); // this line actually does the image resizing, copying from the original // image into the $tmp image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // now write the resized image to disk. I have assumed that you want the // resized, uploaded image file to reside in the ./images subdirectory. $filename = "../users/images/". $_FILES['file']['name'][i]; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request // has completed. endforeach; } <form name="addImages" method="post" enctype="multipart/form-data" action="album.php?album=<?php echo $_GET['album']; ?>"> <table class="columntable"> <tr> <td><input name="file[]" type="file" id="file[]" /></td> <td><input name="file[]" type="file" id="file[]" /></td> </tr> <tr> <td><input name="file[]" type="file" id="file[]" /></td> <td><input name="file[]" type="file" id="file[]" /></td> </tr> <tr> <td><input name="file[]" type="file" id="file[]" /></td> <td><input name="file[]" type="file" id="file[]" /></td> </tr> <tr> <td><input name="file[]" type="file" id="file[]" /></td> <td><input name="file[]" type="file" id="file[]" /></td> </tr> <tr> <td colspan="2"> <input type="submit" name="upLoadImages" value="Add Photos" /> <input name="clear" type="reset" id="clear" value="Reset" /> </td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.