I am new with php and I tried this example to upload file in php
http://phppot.com/php/mysql-blob-using-php/
With following form:
<form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload">
<label>Upload Image File:</label><br/>
<input name="userImage" type="file" class="inputFile" />
<input type="submit" value="Submit" class="btnSubmit" />
</form>
Actually i want to add one more input with type text. So form will become:
<form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload">
<label>Upload Image File:</label><br/>
<input name="userImage" type="file" class="inputFile" />
<input type="text" name="imageinfo"/>
<input type="submit" value="Submit" class="btnSubmit" />
</form>
and script to upload file is:
<?php
if(count($_FILES) > 0) {
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
//$connection = mysqli_connect('localhost', 'username', 'password', 'database');
$l=mysqli_connect("localhost", "root", "password","test");
//mysql_select_db ("test");
$imgData =addslashes(file_get_contents($_FILES['userImage']['tmp_name']));
$imageProperties = getimageSize($_FILES['userImage']['tmp_name']);
$sql = "INSERT INTO output_images(imageType ,imageData)
VALUES('{$imageProperties['mime']}', '{$imgData}')";
$current_id = mysqli_query($l,$sql) or die("<b>Error:</b> Problem on Image Insert<br/>" . mysql_error());
if(isset($current_id)) {
header('Location: listImages.php');
}
}
}
?>
File uploads come through $_FILES. Everything else comes through $_POST, so you can just query $POST['imageinfo']