繁体   English   中英

该图像未存储在数据库PHP中

[英]the image is not store in database PHP

当用户需要添加事件时,我必须使用此代码,他必须使用广告的上传图片填写表单信息

 <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>

在neweventphp中,我编写了此代码

<?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')");

?>

问题是图片未存储在数据库中:(您能帮我吗

您需要像这样将enctype='multipart/form-data到表单中:

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

因此,您可以从文件中发送数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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