Hey iv got a script that lets a user upload an image, the script collects the file and stores it in a table ("displaypic_$user").
What im tryin to do is on a certain page display a smaller version of this image the code iv wrote doesnt error, but it also doesnt work nothing is displayed.
The image displayed fine before i tried to resizee it..heres the code to store the file🙂
if ($submit) {
$conn = mysql_connect("localhost","user","pass");
mysql_select_db("db");
$sql0 = "DELETE FROM displaypic_$user WHERE id='1'";
$empty= @mysql_query($sql0, $conn )
or die(" Could not delete pic");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$id= "1" ;
$result=mysql_query("INSERT INTO displaypic_$user (id,description,bin_data,filename,filesize,filetype) ".
"VALUES ('$id','$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
} else {
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<h5>Upload Picture 1</h5>
Description for picture 1 <br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="220000">
<br>
Choose image to upload for picture 1 (images must not be bigger than 200KB) <br>
<input type="file" name="form_data" size="40">
</p>
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
heres the code that once called from <div class="#PicShow" id="PicShow"><img src="ProfilePic.php" /></div> should show the resized image
<?php
$user = $_COOKIE['username'];
@mysql_connect("localhost","user","pass");
@mysql_select_db("db");
$query = "select bin_data,filetype from displaypic_$user where id=1";
$result = @mysql_query($query);
$image = @mysql_result($result,0,"bin_data");
$type = @mysql_result($result,0,"filetype");
$width = imagesx($image);
$height = imagesy($image);
$new_width = 150;
$new_height = 250;
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
header( "Content-type: $type");
echo $image_resized;
?>
Any help would be great i have searched for tutoirals but apart from the one iv used to write this sript they are mostly for images that are stored in a folder not in mysql
thanks🆒