doutao4480 2016-01-12 05:53
浏览 40

too long

This question is an exact duplicate of:

I'm doing my project in bootstrap. there is an option for image upload in it, but i cant upload it in to my database.

boot.html:

<div class="form-group">
  <label class="col-md-4 control-label" for="imgu">Upload images if / any</label>
  <div class="col-md-4">
    <input id="file" name="file" class="input-file" type="file">
  </div>

php file:

<?php
$a=$_POST['cname'];
$b=$_POST['subject'];
$c=$_POST['cat'];
$d=$_POST['cmp'];
$e=$_POST['cweb'];

move_uploaded_file($_FILES["file"]["tmp_name"],$_FILES["file"]["name"]);
$x=$_FILES["file"]["name"];

mysql_connect("localhost","root","");
mysql_select_db("com");
$sql=mysql_query("insert into cd values('$a','$b','$c','$d','$e','$x')");

if(!$sql)
{
echo "not Inserted";
}
else
{
header("location:home.php");
}
?>

If there any mistakes with this code please do help me

</div>
  • 写回答

3条回答 默认 最新

  • duanjianl183188 2016-01-12 05:56
    关注

    Add this attribute in your form tag :

    enctype="multipart/form-data"

    评论

报告相同问题?