Jump to content

Copy Image then resize


doddsey_65

Recommended Posts

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(); 
?>

Link to comment
https://forums.phpfreaks.com/topic/182881-copy-image-then-resize/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.