简体   繁体   中英

the image is not store in database PHP

I have this code when user need to add event he must fill the form information with upload pic for ads

 <form action="newevent.php" method="post">
<table>
<tr>
    <td> Title :</td>
    <td><input type='text' name='title'/></td>
</tr>
<tr>
      <td colspan="4">Add Your Ads 
      <input type='file' name='ads'/>
      </td>
</tr>
</table>
</form>

in neweventphp i written this code

<?php
$target_folder = "project_img/";
$target_file = $_FILES['ads']['name'];
$target_file_path = $target_folder.$target_file;

if(move_uploaded_file($_FILES['ads']['tmp_name'], "company_img/".$_FILES['ads']['name']))
              {echo "";}

$title=$_POST['title'];

$query1=mysql_query("INSERT INTO event VALUES('','$title','$target_file_path')");

?>

the problem is the pic is not store in database :( Could you help me plz

You need to add enctype='multipart/form-data to your form like this:

 <form action="newevent.php" method="post" enctype='multipart/form-data'>

So you can send the data from your files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM