Programming in almost language

This is the site where you may share your knowledge and experience to eachother..

  • Categories

  • LinkedIn

  • Tweet Me

  • My footsteps

Code for Uploading Image in Database

Posted by Praveen Kumar on November 4, 2008

(Posted by Rishi Chandwani)

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN””&gt;
<html xmlns=””&gt;

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />

<title>Image Upload</title>

echo ‘<p>Please select a file</p>’;
echo ‘<p>Thank you for submitting</p>’;
catch(Exception $e)
echo $e->getMessage();
echo ‘Sorry, could not upload file’;

function upload()
// check the file is less than the maximum file size
if($_FILES[‘TxtImg’][‘size’] < $maxsize)
// prepare the image for insertion
// $imgData = addslashes($_FILES[‘userfile’]);

// put the image in the db…
// database connection

mysql_connect(“localhost”, “$username”, “$password”) or die(“Unable to Connect”);

// select the db
mysql_select_db (“$db”) or die(“Unable to select db”);

// our sql query
$sql=”insert into test values (‘$fnm’, ‘$lnm’, ‘$imgData’)”;

// insert the image
echo ‘Unable to upload file’;

echo ‘Upload Successful’;
echo “File Size Greater than Required”;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: