Jaan,
I have been working through your tutorial but I have missed something as the output is still coming out in code rather then the image. Example: studiosgroup.co.uk/don/viewimg.php?imgid=001. Thanks for you help
Hmm well your ID can't be like that.. ?imgid=001 it must be and it is ?imgid=1 because this ID is automatically generated..
This is the code that I am using to insert the image into the database:
As you can see I am calling an empid so that I can preform a one to many relationship with tbl_Emp and tbl_images (for example) I am then passing the empid to the veiwimg.php to call up all the images for that emp. Make sence?Code:<?php
// Create MySQL login values and
// set them to your login information.
include "includes/functions.php";
include "includes/config.php";
require_once "includes/db.php";
// Make the connect to MySQL or die
// and display an error.
$d = new dbC();
$d->connect($db_host, $db_user, $db_pass, $db);
if (!$d) {
die('Could not connect: ' . mysql_error());
}
// Select your database
//mysql_select_db ($database);
// Make sure the user actually
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];
// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
// Create the query and insert
// into our database.
$query = "INSERT INTO tbl_images ";
$query .= "(image, Memberno) VALUES ('$data','$_POST[memberno]')";
$results = mysql_query($query);
// Print results
print "Thank you, your file has been uploaded.";
echo $empid;
}else{
print "No image selected/uploaded";
}
// Close our MySQL Link
$d->close();
?>
Last edited by WingedPanther; 06-10-2009 at 11:28 AM. Reason: add code tags (the PHP sheet)
Hi, thanks a lot for your tutorial!
May i ask if i can display a picture of students on excursion with comments from teachers, parents and fellow students, with all pictures and comments stored in a database. All the information is on the same page, something like a report.
Thanks a lot in advance,
Lee
good code
Hi,
I have been following the forum. I tried display image. It worked. Thanks!
I have question on that. How do we set the image size to display?
well.. this script displays you the full image.. if you use other GD functions then you can resize this picture if you want..
Hi,
Apparently many people get this to work but after days of trying all different kinds of scripts I still can seem to get a picture showing on my page.
I have copied your tutorial exactly but the best so far was when I got a pop-up asking me if I wanted to download the picture.
How can I actually get this picture in a web page, i.e. how do I call it?
Thanks, I'd appreciate any help..
well.. you display it like this
HTML Code:<img src="image.php?id=1" />
There are currently 3 users browsing this thread. (0 members and 3 guests)
Bookmarks