mysql - How to upload image in php with other it's information -
i new php , tried example 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 want add 1 more input type text. form 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 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 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. else comes through $_post, can query $post['imageinfo']
Comments
Post a Comment