Hallo leute..
Step1:
CREATE TABLE `images` (
`ImageId` int(10) NOT NULL AUTO_INCREMENT,
`Image` longblob,
`FileType` varchar(32) DEFAULT NULL,
PRIMARY KEY (`ImageId`)
)
Update file
ich bekomm jedesmal eine fehlermeldung,wenn ich ein bild hochladen will
No database selected
warum?:suspekt:
Step1:
CREATE TABLE `images` (
`ImageId` int(10) NOT NULL AUTO_INCREMENT,
`Image` longblob,
`FileType` varchar(32) DEFAULT NULL,
PRIMARY KEY (`ImageId`)
)
Update file
PHP:
<?php
if ($_POST['Submit']) {
if ($_POST['MAX_FILE_SIZE'] >= $_FILES['file']['size']) {
//print_r($_FILES);
mysql_connect("localhost", "+++++", "+++++") or die(mysql_error());
mysql_select_db("images");
$photo = addslashes(fread(fopen($_FILES['file']['tmp_name'], "r"),
$_FILES['file']['size']));
$query = sprintf("INSERT INTO images(Image, FileType) VALUES
('%s', '%s')", $photo, $_FILES['file']['type']);
if (mysql_query($query)) {
$messages[] = "Your files is successfully store in database";
} else {
$messages[]= mysql_error();
}
} else {
$messages[]="The file is bigger than the allowed size please resize";
}
}
?>
<html>
<head>
<title>Add Image</title>
</head>
<body>
<?
if (isset($messages)) {
foreach ($messages as $message) {
print $message ."<br>";
}
}
?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<input type="hidden" name="MAX_FILE_SIZE" value="96000000">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
ich bekomm jedesmal eine fehlermeldung,wenn ich ein bild hochladen will
No database selected
warum?:suspekt: