html - Uploading Images in PHP Error -


php code: insert.php

<?php // create mysql login values , // set them login information. $username = "root"; $password = ""; $host = "localhost"; $database = "binary";  // make connect mysql or die // , display error. $link = mysql_connect($host, $username, $password); if (!$link) { die('could not connect: ' . mysql_error()); }  // select database mysql_select_db ($database);   // make sure user // selected , uploaded file if (isset($_files['image']) && $_files['image']['size'] > 0) {  // temporary file name stored on server $tmpname = $_files['image']['tmp_name'];  // read file $fp = fopen($tmpname, 'r'); $data = fread($fp, filesize($tmpname)); $data = addslashes($data); fclose($fp);   // create query , insert // our database. $query = "insert tbl_images "; $query .= "(image) values ('$data')"; $results = mysql_query($query, $link);  // print results print "thank you, file has been uploaded."; } else { print "no image selected/uploaded"; }  // close our mysql link mysql_close($link);  ?>     ?>  

html code: add.html

 <form enctype="multipart/form-data" action="insert.php" method="post" name="changer">  <input name="max_file_size" value="102400" type="hidden">  <input name="image" accept="image/jpeg" type="file">  <input value="submit" type="submit"> 

right trying upload image save image mysql database. problem either not uploading file correctly, or not correctly transferring image insert.php file. when upload file displays correct suggesting uploaded, after click submit, echos no image selected/uploaded ?> command told if can not data add.html post. me figure out what's going on?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -