doddsey_65 Posted November 25, 2009 Share Posted November 25, 2009 Hi, I currently have an image upload system in place which works fine but what i want is for the user to upload an image then the image is copied, one of them is sent to uploads/ and the other is resized and sent to uploads/thumb. Is this possible? Heres my code at the moment: <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $uploadDir = 'public/thumbs/'; if(isset($_POST['upload2'])) { $fileName = $_FILES['userfile2']['name']; $tmpName = $_FILES['userfile2']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $link= $fileName. '.php'; $sql="INSERT INTO publicgallery (path, paththumb, name, username, description, link) VALUES ('$filePath','$_POST[rendername]','$_POST[username]','$_POST[description]', '$link')"; $result = mysql_query($sql, $db); echo '<br><br> <div id="page"> <div id="content"> <div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p> <div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back. </div></div></div>'; include('footer.php'); } ob_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/182881-copy-image-then-resize/ Share on other sites More sharing options...
Stuie_b Posted November 26, 2009 Share Posted November 26, 2009 yes you can you will need to use one of the GD2 libs to achieve it, your best bet is to use imagejpeg or ImageCopyResampled See here for info on using imagejpeg and here for ImageCopyResampled Stuie Quote Link to comment https://forums.phpfreaks.com/topic/182881-copy-image-then-resize/#findComment-965761 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.