I’m getting this message after pressed upload button. Help please.
Array ( )
Warning: fread(): supplied argument is not a valid stream resource in C:wampwwwMyAdmintratorTempaddPhoto.php on line 7
<?php
if ($_POST[‘Submit’]) {
if ($_FILES[‘file’][‘size’]) {
print_r($
mysql_connect(“localhost”, “root”, “”) or die(mysql_error());
mysql_select_db(“test”);
$photo = addslashes(fread(fopen($_FILES[‘file’][‘tmp_name’], “rb”), $
$query = sprintf(“INSERT INTO image(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=”96000″>
<input type=”submit” name=”Submit” value=”Submit”>
</form>
</body>
</html>