Urgent --- Saving png image created with php functions
Posted: Tue Aug 08, 2006 6:59 pm
Pimptastic | Please use
Thank you
rav
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello:
I have created png image which inserts the text over the image
and creates a new image on fly with php image creation functions...
Now, I want to save this text image in the database...
How do i do it as this image is getting created on fly with php image creation functions???
I will appreciate your early reply..
..I am trying to uinsert into database... as follows
I get data from a form and create text image and then trying to insert
I can see image with text..but i am not able to insert in database
Inserting process code....Code: Select all
<?php
header("Content-type: image/png");
$desc= $_POST['desc'];
include 'config1.php';
include 'opendb.php';
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$im = imagecreatefrompng($tmpName);
$orange = imagecolorallocate($im, 0, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($desc)) / 2;
imagestring($im, 3, $px, 9, $desc, $orange);
imagepng($im);
$content = addslashes($im);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query = "INSERT INTO imgtable (name, size, type, image, description ) VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$desc')";
mysql_query($query) or die('Error, query failed');
$pid= mysql_insert_id();
echo " <div align='center'>You have successfully added the Image! <a href='stickyView.php'>Click here to view</a></div>";
imagedestroy($im);
}
else
{
echo "<div align='center'>Please enter full record. <a href='productAdd.php'>Click here to Enter</a></div>";
}
?>Thank you
rav
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]