Just saw this for the first time...
Great tutorial +rep![]()
I'm not too sure on the uploading of file types - but you do need to declare the mime type for them to display correctly.
Or, at least that's my understanding of the subject. If you declare a mime type of jpg and output a pdf file - it won't display correctly.
If anyone knows different, please correct me.
Phill.
I do understand that you need the correct mime type to display the image.
My question is for uploading the image.
Jon
Cant wait in the nest tutorial i relly nid this tutorial for our proposal project in schools![]()
This is my code
But in the database or the images/jpeg dot show image or anything in the databaseCode:<?php
require_once("startsession.php");
include_once("mysql.php");
$database = "binary";
?>
<form enctype="multipart/form-data" action="" method="post" name="changer">
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
<?php
// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// Select your database
mysql_select_db ($database);
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) VALUES ('$data')";
$results = mysql_query($query, $link);
// Print results
print "Thank you, your file has been uploaded.";
}
else {
print "No image selected/uploaded";
}
// Close our MySQL Link
mysql_close($link);
?>
Hi!,
I am looking for the full script of image into database and show in php.After lot of searches I found your script which is working till ad.html and image into mysql.The real problem is like it is only showing show.php as Please select your image!.
I am not understanding where did the error occur.i even downloaded you script and tried the same thing is what it says.Please do help me its urgent for me for a portal I am doing where I need to upload images for each person registering and displaying their details.
Thanks and Regards,
Ram.
This will be of great help to people. You have done a great job.
The original poster is no longer with CodeCall. If you have any question regarding this posting, please start a new thread in the appropriate section of the forum (and reference this thread).
Thank you.
There are currently 7 users browsing this thread. (0 members and 7 guests)
Bookmarks