Hi, i’ve been working with my website for quite some time now.
Its a simple upload button which uploads your selected image to a MYSQL server + a folder on my computer (the website is not live!!)
Now the problem is that I can’t echo out the image or display it in anyway.
Im gonna show my code below.
Just some quick info-
It works to upload the picture to the server AND the folder called ‘imagess’ on my computer but displaying the image wont work. Please help!
Server database name is: server_upload
table name: storeimg
I will show the code below:
this is the file called indexform.php-
[php]
Upload an image File: <?php //error_reporting(E_ALL ^ E_NOTICE); //connecting phase mysql_connect("localhost","roott","hej") or die(mysql_error()); mysql_select_db("server_upload") or die(mysql_error()); $file = $_FILES['image']['tmp_name']; if (!isset($file)) echo "Please select an image."; else { $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size==FALSE) echo "That's not an image."; else { if ($insert = mysql_query("INSERT INTO storeimg VALUES ('','$image_name','$image')")) echo "Success uploading.Your image:
"; else { $lastid = mysql_insert_id(); echo "Image uploaded.
Your image:
";
}
}
}
//blobtel
if (isset($_FILES['image'])) {
$errors = array();
$allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
$file_name = $_FILES['image']['name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
if ($file_size > 2097152) {
$errors[] = 'File size must be under 2mb';
}
if (empty($errors)) {
if (move_uploaded_file($file_tmp, 'imagess/'.$file_name)) {
echo '';
}
}
else {
foreach ($errors as $error) {
echo $error, '
';
}
}
}
?>
[/php]
And this is the file called get2.php:
please note that i’ve hidden alot of my previous attempts with // but I want them to stay there for now.
[php]
Looking forward to your help!
And the problem was that I cant seem to echo out / display the image on the website.