0
I’m developing a system that needs up 2 types of img
a small and a large for the database but when I send up 3 img
small and 3 img
great test my foreach
does not go up all the img
small or their respective it rises only the 3 img
Big he even climbs 3 img
small but he repeats the first 3 times someone can help me?
Code:
require"conexao.php";
if(isset($_POST['port'])){
//dados que serão incluidos
$nome = $_POST['galeria'];
foreach($_FILES['imgp']['tmp_name'] as $key => $name_temp){
$name = $_FILES['imgp']['name'] [$key];
$tmpnm = $_FILES['imgp']['tmp_name'][$key];
$type = $_FILES['imgp']['type'][$key];
$size = $_FILES['imgp']['size'][$key];
$dir = "../images/small/portfolio/".$name;
$mover = move_uploaded_file($tmpnm , $dir);
foreach($_FILES['imgb']['tmp_name'] as $k => $n){
$nomev = $_FILES['imgb']['name'] [$k];
$t = $_FILES['imgb'] ['tmp_name'] [$k];
$tipo = $_FILES['imgb']['type'][$k];
$tam = $_FILES['imgb']['size'][$k];
$dire = "../images/big/portfolio/".$nomev;
$move = move_uploaded_file($t , $dire);
if($mover&&$move){
$sql = mysqli_query($mysqli, "INSERT INTO portfolio(nome, img, type, size, img_big, tipo, tam)
values('$nome', '$name', '$type', '$size', '$nomev', '$tipo', '$tam')") or die (mysqli_error());
if($sql){
echo "foi";
}
else{
echo "erro database";
}
}else{
echo"<h1>Ocorreu um erro.</h1>";
}
}
}
}
The problem would be that the big pictures are repeating?
– Pedro Erick
the little ones are repeating the big ones so going right
– Leonardo Costa
if I climb 3 small and 3 large he will catch the 1 small q climbed and will repeat her 3x. but the big he will climb normal
– Leonardo Costa
Probably your problem is the foreach of the large images inside the foreach of the small images, it should repeat all large images for each small image. I can’t see the small image being repeated from here, maybe if you run a few more tests and post more information maybe it will be easier to help you.
– Pedro Erick
Right what you said I’ve used the
var_dump()
to see the results of the firstforeach
he doesn’t pass by all he always stops at the firstimg
already the second takes everything normal. what I must do for them to work the way he climbs all theimg
small and all theimg
great?– Leonardo Costa
I put a response with a code that should approximate what you need, test it and report the result later.
– Pedro Erick