Take the 2-minute tour ×

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">
    <td> Title :</td>
    <td><input type='text' name='title'/></td>
      <td colspan="4">Add Your Ads 
      <input type='file' name='ads'/>

in neweventphp i written this code

$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 "";}


$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

share|improve this question
your code doesn't store the picture in the db, it stores the path., your image is stored in the file system. –  Ibu Mar 27 '13 at 17:59
I am not sure if the path saved in the database or not because of slashes, any way, database is not place for saving pictures, you can just save the path in the db and the file on desk, then, you can load the image next time by using src='path' –  user1646111 Mar 27 '13 at 18:02
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
Thanks A lot Dear Ares ^_^ –  mnora_h Mar 27 '13 at 18:03
add comment

Your Answer


