日期:2014-05-17  浏览次数:20409 次

图片批量上传成功后,如何将路径与其他字段一同插入数据库?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>图片批量上传</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
-->
</style>
</head>
<body>
请选择要上传的文件
<form action="" method="post" enctype="multipart/form-data">
<table id="up_table" border="1" bgcolor="f0f0f0" >
     <tbody id="auto">
        <tr id="show" >
         <td>小图 </td>
   <td><input name="u_file[]" type="file"></td>
   </tr>
    <tr>
         <td>中图 </td>
   <td><input name="u_file[]" type="file"></td>
   </tr>
       <tr>
         <td>大图 </td>
   <td><input name="u_file[]" type="file"></td>
   </tr>
   </tbody>
  <tr><td colspan="4"><input type="submit" value="上传" /></td></tr>
  <tr>
    <td colspan="4">图片说明:<input type="text" name="wd" size="42" maxlength="100" /></td>
  </tr>
</table> 
</form>
<?php

$destination_folder = "picture/"; 

if(!file_exists($destination_folder))
    {
        mkdir($destination_folder);
    }

foreach ($_FILES["u_file"]["error"] as $key => $error) { 
      if ($error == UPLOAD_ERR_OK) { 
         $tmp_name = $_FILES["u_file"]["tmp_name"][$key]; 
          $name     = $_FILES["u_file"]["name"][$key]; 
       $uploadfile = $destination_folder.time().$name; 
          move_uploaded_file($tmp_name, $uploadfile); 
       echo '文件'.$name.'上传成功,图片路径:'.$uploadfile.'<br>';

      } 

?>
</body>
</html>


红色部分为三张图片上传成功后显示的图片路径
然后在图片说明里,输入说明文字,请问3张图片的路径如何连同输入的图片说明内容一起提交到数据库?
例如数据库为:picture,对应字段分别为picid,p_explain(图片说明),s_pic(小图路径),m_pic(中图路径),b_pic(大图路径)