Bricktop Posted June 16, 2008 Share Posted June 16, 2008 Hello chaps, Just a quick favour if I may? I have a simple image upload script which I implemented for a friend. However, the pictures they are uploading are really quite large and I would like my script to resize the image to 800 * 600 on upload. I have tried to implement this but it's not working and I can't figure it out. Below is the unmodified upload code: function uploadImage() { global $settings; $path = $settings['uploadpath']; $filename = $_FILES['image']['name']; $description = $_POST['description']; if ( $filename == "" ) { $content = '<font color="red">Please select a file to upload</font>'; $time = 4; } else { move_uploaded_file( $_FILES['image']['tmp_name'] , $settings['uploadpath'] . $_FILES['image']['name'] ); if (strlen($_FILES['image']['name']) > 0) { chmod($settings['uploadpath'] . $_FILES['image']['name'], 0644); } Would someone be kind enough to repost my code with the relevant changes to make the script resize please? Thanks very much. Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/ Share on other sites More sharing options...
vbnullchar Posted June 16, 2008 Share Posted June 16, 2008 i think this article can help you... http://www.sitepoint.com/article/image-resizing-php Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/#findComment-566326 Share on other sites More sharing options...
Bricktop Posted June 16, 2008 Author Share Posted June 16, 2008 Thanks for the link but this resize script simply resizes the dimensions of an image already held on the server. It does not make the image any smaller in size. What I want to do is resize the image as it is uploaded - so the image gets uploaded to the file server as the resized image, thus making a smaller file size. Thanks Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/#findComment-566332 Share on other sites More sharing options...
Bricktop Posted June 16, 2008 Author Share Posted June 16, 2008 Sorry to bump this but just wondered if anyone else knew where I was going wrong? Thanks Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/#findComment-566500 Share on other sites More sharing options...
rhodesa Posted June 16, 2008 Share Posted June 16, 2008 You can't resize the image before or "as it's uploaded" (as far as I know). The person would have to resize it themselves with an image app on their computer before uploading. The normal process is upload full image, resize & save as smaller. The only thing I can think of is some Java app, which might be able to handle it all client side, but I'm not aware of anything like that. Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/#findComment-566510 Share on other sites More sharing options...
Bricktop Posted June 17, 2008 Author Share Posted June 17, 2008 Thanks for the replies chaps - I got it working and it is possible to resize as the file is uploaded. For those who may search the forums for an answer to a similar problem in future, please take a look at this excellent tutorial and code snippet here http://www.4wordsystems.com/php_image_resize.php. Works a treat on my script! Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/#findComment-567114 Share on other sites More sharing options...
rhodesa Posted June 17, 2008 Share Posted June 17, 2008 That still uploads the FULL file THEN resizes it once it's on the server Link to comment https://forums.phpfreaks.com/topic/110387-solved-image-resize/#findComment-567180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.