while uploading a image using php and mysql: Warning: file_get_contents(): Filename cannot be empty -
when trying upload image photos folder having type of warning msg dont know to.. this php file
if (!isset($_files['image']['tmp_name'])) { echo ""; }else{ $file=$_files['image']['tmp_name']; $image= mysql_real_escape_string(addslashes(file_get_contents($_files['image']['tmp_name']))); $image_name= addslashes($_files['image']['name']); move_uploaded_file($_files["image"]["tmp_name"],"photos/" . $_files["image"]["name"]); $location="photos/" . $_files["image"]["name"]; $save=mysql_query("insert add values('$location')") or die("can not insert"); exit(); }
this html code
<form method="post" action='ap.php' enctype="multipart/form-data"> <input name="image" id="image" type="file" /> <input type='submit' name='add' value='add' /> </form>
no need following lines:
$image= mysql_real_escape_string(addslashes(file_get_contents($_files['image']['tmp_name']))); $image_name= addslashes($_files['image']['name']);
just removed , test work. checking first if condition enough.
Comments
Post a Comment