<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(大图路径)
上传数据库图片
<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(大图路径)
上传数据库图片
解决方案 »
- 菜鸟请教高手来帮个忙,关于行列的问题(有代码,有图)
- php 调用 java 的配置问题(linux下)
- dedecms5.5圈子二级分类多显示不全该如何修改?
- 刚学习,写得php分页附源码
- 看下我上传图片的源码那有问题!上传完图片不显示所在目录
- 新浪开放平台的API接口上服务器就无法返回数据,本地测试正常,请问怎么解决?
- 如何在学校的内伤上搭建一个资源共享平台
- 有人用PHP+DWZ框架做后台吗?
- php读取csv文件乱码
- 请教php 密码项怎么写
- nicetmeetu Zend Studio Debug出现错误提示“No tests in xxx”
- imagerotate用不了,php版本5.2.17,怎样解决?
echo '文件'.$name.'上传成功,图片路径:'.$uploadfile.'<br>';
$arr[]=$uploadfile;
}
$sql="insert into picture values('','$_POST['wd']','$arr[0]','$arr[1]','$arr[2]')";
mysql_query($sql);
insert into tableName(AA, BB, CC) values(1, 1, 1),(2, 2, 2);
sql语句可以在foreach循环上传时拼接,成功后执行
Array ( [0] => picture/13703303631.jpg )
Array ( [0] => picture/13703303631.jpg [1] =>picture/13703303632.jpg )
Array ( [0] => picture/13703303631.jpg [1] =>picture/13703303632.jpg [2] => picture/13703303633.jpg )