Php 多个文件上载,如何包含更多字段并向数据库添加完整路径

Php 多个文件上载,如何包含更多字段并向数据库添加完整路径,php,mysql,Php,Mysql,我发现一些代码可以将文件上载到服务器上的文件夹,然后将路径保存到数据库表列。表格的代码: <form method="post" action="add_member.php" enctype="multipart/form- data"> <p>Please Upload a Photo of the Member in gif or jpeg format. The file name should be named after the Members nam

我发现一些代码可以将文件上载到服务器上的文件夹,然后将路径保存到数据库表列。表格的代码:

 <form method="post" action="add_member.php" enctype="multipart/form-
 data">
<p>Please Upload a Photo of the Member in gif or jpeg format. The file  
name should be named after the Members name. If the same file name is  
uploaded twice it will be overwritten! Maxium size of File is 35kb.
</p>
        <p>
          Photo:
        </p>
        <input type="hidden" name="size" value="350000">
        <input type="file" name="cert_1">
           <br/>
            <br/>
          <input TYPE="submit" name="upload" title="Add data to the 
Database" value="Add Member"/>
</form>
现在,我需要将文件上载字段的数量增加到至少四个,然后分别将文件的完整路径写入数据库列。该脚本工作得很好,但只是没有将完整路径写入数据库,因此我可以稍后调用它并在应用程序中显示。“任何好人”能帮上忙吗?事实上,这让我头疼

提前感谢您的宝贵建议


堆叠溢出的岩石

您需要支持html5的浏览器进行多次上传或使用不同的技术:java小程序、flash、silverlight。
jquery有一个用于多次上传的插件:

您容易受到攻击。这里回答了警告:如果您只是在学习PHP,请不要使用该接口。它是如此可怕和危险,以至于在PHP7中被删除。替换类和指南类说明了最佳实践。您的用户参数不存在,并且存在可利用的参数。谢谢@tadman,我一定会这么做。也谢谢你,马克B。我看了艾玛一眼。谢谢我最终找到了一个带有新jquery插件的安全was。我还反驳说使用PDO,“你需要支持html5的浏览器来进行多次上传”——其实不是这样;PHP可以处理倍数。Java小程序?银灯?闪光取决于其中任何一个都是错误的,他们要么死了,要么就要死了。HTML5几乎受到所有东西的支持,不必担心将jQuery与之结合使用。@Fred ii-只有支持HTML5的浏览器才能发送多个文件或java applet/flash/silverlight。我没有提到服务器端。塔德曼:你检查过世界上html5浏览器的使用情况吗?我试图让用户注意选择正确的技术来解决这个问题。这很有效。谢谢mkysoft,我不知道我是否想在目前使用flash的成本和支持很少的情况下,一直使用小程序。我认为jQuery将所有这些都整合到了一起。
//This is the directory where images will be saved
 $target = "upload";
 $target = $target . basename( $_FILES['cert_1']['name']);

 //This gets all the other information from the form

   $pic=($_FILES['cert_1']['name']);



// Connects to your Database
mysql_connect("host", "db_user", "_db_pass") or         

die(mysql_error()) ;
mysql_select_db("your_db") or die(mysql_error()) ;

//Writes the information to the database
mysql_query("INSERT INTO student_biodata_master 
           (cert_1)
           VALUES ('$pic')") ;

//Writes the photo to the server
if(move_uploaded_file($_FILES['cert_1']['tmp_name'], $target))
{

//Tells you if its all ok
echo "The file ". basename( $_FILES['cert_1']['name']). " has been  
uploaded, and your information has been added to the directory";
}
else {

//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}