i am gettin the foll error when i click submit
is_uploaded_file() expects parameter 1 to be string
th code:
<?php
if(!isset($_FILES['userfile'])) {
echo '<p>Please select a file</p>';
}
else
{
try {
upload();
echo '<p>Thank you for submitting</p>';
}
catch(Exception $e) {
echo $e->getMessage();
echo 'Sorry, could not upload file';
}
}
?>
<?php
print_r($_POST[name]);
function upload(){
if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
if($_FILES['userfile']['size'] < $maxsize)
{
$imgData =addslashes (file_get_contents($_FILES['userfile']['tmp_name']));
$size = getimagesize($_FILES['userfile']['tmp_name']);
$username='root';
$password='admin';
mysql_connect("localhost", "$username", "$password") OR DIE (mysql_error());
// select the db
mysql_select_db ("$dbname") OR DIE ("Unable to select db".mysql_error());
$sql = "INSERT INTO testblob
( image_id , image_type ,image, image_size, image_name)
VALUES
('', '{$size['mime']}', '{$imgData}', '{$size[3]}', '{$_FILES['userfile']['name']}')";
if(!mysql_query($sql)) {
echo 'Unable to upload file';
}
}
}
else {
// if the file is not less than the maximum allowed, print an error
echo
'<div>File exceeds the Maximum File limit</div>
<div>Maximum File limit is '.$maxsize.'</div>
<div>File '.$_FILES['userfile']['name'].' is '.$_FILES['userfile']['size'].' bytes</div>
<hr />';
}
}
?>
<html>
<head><title>File Upload To Database</title></head>
<body>
<h3>Please Choose a File and click Submit</h3>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<input name="userfile[]" type="file" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

