Question

i want to upload data by this form

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

i have no problem when i upload photos

bu when i insert data to database i have a problem

this is my code

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>';
}
Was it helpful?

Solution

try replacing

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

with

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

This should work

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top