Hey i think im pretty much there with this bit of code iv been trying to get it to work for aaages i think im close im not getting any errors anyway,
What iv got is an upload form for a image, the image is there stored in a folder.
What im trying to do is also resize the image and save a smaller version in a diffrent folder.
This bit of code works fine this is where the image in its original size is stored
$auth = $_COOKIE['auth'];
$user = $_COOKIE['username'];
if ($userfile_size >250000){$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload.<BR>";
$file_upload="false";}
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";}
$add="DisplayPic/$user.jpg"; // the path with the file name where the file will be stored, upload is the directory name.
if(move_uploaded_file ($userfile, $add)){
// do your coding here to give a thanks message or any other thing.
}else{echo "Failed to upload file Contact Site admin to fix the problem";}
$conn = mysql_connect("localhost","******","******");
mysql_select_db("******");
$path = "DisplayPic/$user.jpg";
$sql0 = "DELETE FROM displaypic_big WHERE user= '$user'";
$empty= @mysql_query($sql0, $conn )
or die(" Could not empty");
$sql = ("INSERT INTO displaypic_big (`user`,`path`) ".
"VALUES (\"$user\",\"$path\")");
$result= @mysql_query($sql, $conn )
or die(" Could not delete pic");
header("Location: ./EPDisplayPic.php");
This is the bit of code that is supposed to resize the image and store it in a diffrent folder its not producing any errors but its also not saving the image
// make tmep file
$uploadedfile = $_FILES['userfile']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
// get size of image
list($width,$height)=getimagesize($uploadedfile);
// set resize er size
$newwidth=100;
$newheight=($height/$width)*100;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// resize
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
// save resized
$filename = "DisplayPic_Small/$user". $_FILES['userfile']['name'];
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp);
any help with this would be great im thinking its something simple that im just not seeing
cheers🙂