hii,
i have stored the images from form to database in blob format.now i have a necessity to retrieve image from database and store it in a folder ..how to do this..
thanks,
Pradeep
7 7173
Hi, I've found this to be very helpful: http://www.phpriot.com/articles/images-in-mysql
It shows how to display the image on page 8. Hope it helps :o)
If you still need help, post the structure if your table and how you'd like to show the images to the user (ie, <img src="img.php?id=..."> or direct url or what way you'd like to use).
Regards,
Tom
i hve used that script .....but that doesnot work for me bcos i wanted to mail the picture which i am not able to do .so i that of saving the picture fron database to some jpg file and then mailing it....
i am sending the mailing script chk if u can help
[PHP]<?php
mysql_connect("localhost","root","12233");
mysql_select_db("xyz");
$str_sql="select * from pphp where id=184";
//'".$_GET['Id']."'";
$Colloquiums1 = array();
$i=0;
$res_id=mysql_query($str_sql);
while ($sub_row=mysql_fetch_array($res_id)) {
$tmp1 = array(
'Count' => $i+1,
'ID' => $sub_row['ID'],
'pic' => $sub_row['pic']
)
$Colloquiums1[$i++] = $tmp1;
}
$ID=$Colloquiums1[0]['ID'];
$nid=$ID;
$name=strtoupper($Colloquiums1[0]['name']);
$picname=$Colloquiums1[0]['picname'];
$address=$Colloquiums1[0]['address'];
//$pic=print("<img src='/phdstudents/admitcardpic.php?Id=184'>");
// multiple recipients
//$to = 'aidan@example.com' . ', '; // note the comma
//$to .= '<REMOVED-BY-MOD>@gmail.com';
// subject
$subject = 'admitcard';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<div id="textcontent">
<h3>Admit Card</h3>
<table align="center" width="100%" border="1" cellspacing="2" cellpadding="2" id="img1">
<tr>
<td align="left">Ref=' . $ID .'</td>
</tr>
</table>
<table align="center" width="100%" border="0" cellspacing="2" cellpadding="2" id="img1">
<tr>
<td>Name</td>
<td>:</td>
<td><b>' . $name . '</b></td>
/*problem here in mailing the pic*/
<td colspan=2>' . <img src="http://abc.com/abc/pic.php?Id=190"> . '</img></td>
</tr>
<tr>
<td>Address</td>
<td>:</td>
<td><b>' . $address . '</b></td>
</tr>
</table><table>This is a automated email(admitcard) generated.Copyright@IIA.</table>
</body>
</html> ';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: <REMOVED-BY_MOD>@gmail.com, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: webmaster <webmaster@iiap.res.in>' . "\r\n";
$headers .= 'Cc: testcom' . "\r\n";
$headers .= 'Bcc: cc@example.com' . "\r\n";
// Mail it
$ok=mail($to, $subject, $message, $headers);
if($ok){
echo "mail sent";
}
else{
echo "fail";
}
?>
[/PHP]
Hello Pradeep,
I think you you can do this by adding one more header to your mail script. -
$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n";
Now we need the real file name as the attachment, Let me say, I never tried to take it directly from MySQL blob and put it in to header.But I think we can do it( Guys, correct me if I'm wrong here). Why don't you give it a try, until I also do some coding for this.
Accideblty you have added a email address to the script and I am assuming that was your personal email. for your own safety and also because of the rules of our forum I had to remove it.
Atli 5,058
Expert 4TB
I'm not sure this is the best way to send images in emails, but you can "embed" images into HTML by using a data URL scheme as the src.
Like, for example: -
<?php
-
// Fetch the image. Could be replaced with your database data
-
$filename = "img.jpg";
-
$data = file_get_contents($filename);
-
-
// Encode the data and send it using an <img> tag
-
$data = base64_encode($data);
-
echo '<img src="data:image/jpeg;base64,', $data, '" alt="testing..." />';
-
?>
-
A modern browser should display this just like a normal <img> tag using the file name as a src.
I'm not sure this is the best way to send images in emails, but you can "embed" images into HTML by using a data URL scheme as the src.
Like, for example: -
<?php
-
// Fetch the image. Could be replaced with your database data
-
$filename = "img.jpg";
-
$data = file_get_contents($filename);
-
-
// Encode the data and send it using an <img> tag
-
$data = base64_encode($data);
-
echo '<img src="data:image/jpeg;base64,', $data, '" alt="testing..." />';
-
?>
-
A modern browser should display this just like a normal <img> tag using the file name as a src.
Yes, I am just talking about mail with file attachments here. May be the OP is asking about sending inline images with his email. but original post doesn't say anything about it.
hey guys i got thse solution i cld mail picture by using
<img src="http://www.abc.com/pic.php?Id='. $nid .'"></img>
Thanks,
Pradeep
hey guys i got thse solution i cld mail picture by using
<img src="http://www.abc.com/pic.php?Id='. $nid .'"></img>
Thanks,
Pradeep
Hello,
That's not a solution, that's a work-around. To be honest, I don't know the solution to what you need, but you should look into MIME. There are PHP classes out there that support MIME attachments (try looking on google) and you can include images in email messages. Using an <img> tag doesn't help very much because almost all email clients block images and the user has to click on something to unblock them and allow them to load which may not always be acceptable. Also, if someone is saving that email on their computer they might not get the image from some clients, they'll only get the html with the tag so if they'll be disconnected from the Internet or if you decide to change the URL by which the image is accessed, they won't see the image. Another thing to take into account is bandwidth. Every time someone will look at an email, their client will connect to your web server to check if the image has updated and some clients might even re-download the image every time.
The <img> be OK for what you need, but I thought you might want to consider the things from above and decide if you need to use MIME.
Regards,
Tom
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Rob |
last post by:
Ummm...I'm a little stuck on how to approach the following....
I have a mySQL table holding images (fields are: data (blob), name (text),
type (text), size(text), desc (text) )
If I want to...
|
by: David Stockwell |
last post by:
Hi,
I'd like to read the contents of a file into memory. The problem is that
this file is binary. I then want to store the whole thing in memory to a
database as a blob.
I have no problem...
|
by: tracy |
last post by:
I plan to change the datatype from long raw to blob as from tables
stud_photo and cimpant _image below. But i am not sure if it is a good
idea. pls advise.
TQ!
SQL> DESC STUD_PHOTO;
Name ...
|
by: ssp |
last post by:
Dear all,
I'm dealing with a very tricky problem and can't seem to find the
answer with google. the problem is: i want to store huge data
(binaries) inside a mysql databases blob - to later...
|
by: Olav Tollefsen |
last post by:
How can I display photo images stored in a SQL Server 2000 databases in a
DataList or DataGrid without having to write the images to files first?
Olav
|
by: Piedro |
last post by:
Hi group,
how do I read a image/blob field in cas option strict is on?
First I had it turned off and I read it like this:
Dim b() As Byte
If Not dsSupp.Tables(0).Rows(0).Item("BITMAP") Is...
|
by: Mikael |
last post by:
I'm fairly new to Access, however I have decent experience with a variety of programming languages. I created a database for students profiles at my company. The profiles contain various data, plus...
|
by: bananularstyle |
last post by:
Hi everyone,
This is an issue I have been picking away at for the past two weeks and am running short of ideas. :-\ I am writing an ASP page that allows a user to open/save a tif image stored on...
|
by: Connie |
last post by:
I have a column in my table that is an Image (blob). The data stored
in this blob is basically pdf files. I need a query to determine the
total size of these blob's in the database. Here is what...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |