1

我想通过这个表格上传数据

<input type="file" name="upload[]" multiple="" />

我上传照片时没有问题

bu当我将数据插入数据库时​​出现问题

这是我的代码

for ($x = 0; $x<count($file ['name']); $x++){  

$imgname     = $file ['name'] [$x] ;
$imgsize     = $file['size'] [$x];
$imgtmpname  = $file['tmp_name'] [$x];
$imgtype     = $file['type'] [$x];
$size     = 6000000;
$imgtypes    = array('image/jpeg','image/gif','image/png');

$new_name_time = time();
$new_name_rand = rand(0000,9999);
$new_name_md5 = md5($new_name_time);

create_image($imgtmpname, 'files/'.$new_name, $newwidth, $newheight);

$pics[$x] = $new_name;

} // end for

$newdata = (implode("','", $pics));        

$insert = $mysqli->query("INSERT INTO msgs 
(id, yourname, msgmail, msgname, msg, pics) VALUE
('', '$yourname', '$msgmail', '$msgname', '$msg', '$newdata')");

if($insert) {
echo '<div class="msgok">done</div>';
}
4

1 回答 1

0

尝试更换

$newdata = (implode("','", $pics)); 

$newdata = (implode(',', $pics));

这应该工作

于 2013-10-02T19:39:23.270 回答