Php saves the uploaded graph to the database and displays the code. Php saves the uploaded graph to the database and displays the code php Tutorial. saves the uploaded graph to the database tutorial and displays the code Connecttodatabase $ errmsg; if (! @ Mysql tutorial _ connect (loc php saves the uploaded graph to the database and displays the code
In the php Tutorial, save the uploaded graph to the database and show the code.
// Connect to database
$ Errmsg = "";
If (! @ Mysql tutorial _ connect ("localhost", "root ","")){
$ Errmsg = "Cannot connect to database ";
}
@ Mysql_select_db ("db1 ");
$ Q = < Create table pix (
Pid int primary key not null auto_increment,
Title text,
Imgdata longblob)
CREATE;
@ Mysql_query ($ q );
// Insert any new image into database
If ($ _ REQUEST [completed] = 1 ){
Move_uploaded_file ($ _ FILES ['imagefile'] ['tmp _ name'], "latest. img ");
$ Instr = fopen ("latest. img", "rb ");
$ Image = addslashes (fread ($ instr, filesize ("latest. img ")));
If (strlen ($ instr) <149000 ){
Mysql_query ("insert into pix (title, imgdata) values ("".
$ _ REQUEST [whatsit].
"","".
$ Image.
"")");
} Else {
$ Errmsg = "Too large! ";
}
}
// Find out about latest image
$ Gotten = @ mysql_query ("select * from pix order by pid desc limit 1 ");
If ($ row = @ mysql_fetch_assoc ($ gotten )){
$ Title = htmlspecialchars ($ row [title]);
$ Bytes = $ row [imgdata];
} Else {
$ Errmsg = "There is no image in the database yet ";
$ Title = "no database image available ";
// Put up a picture of our training center
$ Instr = fopen ("../wellimg/ctco.jpg", "rb ");
$ Bytes = fread ($ instr, filesize ("../wellimg/ctco.jpg "));
}
// If this is the image request, send out the image
If ($ _ REQUEST [gim] = 1 ){
Header ("Content-type: image/jpeg ");
Print $ bytes;
Exit ();
}
?>
Upload an image to a database
Here's the latest picture
Please upload a new picture and title
The upload php Tutorial saves the uploaded graph to the database tutorial and displays the code // Connect to database $ errmsg =; if (! @ Mysql tutorial _ connect (loc...