Boas a todos.
Tenho usado a classe simpleimage para fazer upload das imagens no site.
Ao fazer upload da imagem adiciono uma marca de agua, mas o meu objetivo agora é fazer upload de varias imagens ao mesmo tempo com apenas um submit. Já estou a usar "enctype="multipart/form-data" no form e multiple="multiple" no input e adocionei [] ao nome do input.
Código (PHP):
Tentei usar este código, mas não consegui chegar lá![:(]()
Código (PHP):
Tenho usado a classe simpleimage para fazer upload das imagens no site.
Ao fazer upload da imagem adiciono uma marca de agua, mas o meu objetivo agora é fazer upload de varias imagens ao mesmo tempo com apenas um submit. Já estou a usar "enctype="multipart/form-data" no form e multiple="multiple" no input e adocionei [] ao nome do input.
Código (PHP):
if( isset($_POST['inserir']) ) {
try {
// gerir unique id
$valor_total = uniqid();
$image = new SimpleImage();
$image->load($_FILES['image'] ['tmp_name']);
$image2 = $_FILES['image']['name'];
$image-> overlay('overlay.png', 'bottom right', .8) ->save('images/fotos/'.$valor_total.$image2.'');
try {
// gerir unique id
$valor_total = uniqid();
$image = new SimpleImage();
$image->load($_FILES['image'] ['tmp_name']);
$image2 = $_FILES['image']['name'];
$image-> overlay('overlay.png', 'bottom right', .8) ->save('images/fotos/'.$valor_total.$image2.'');
Tentei usar este código, mas não consegui chegar lá

Código (PHP):
//Loop through each file
for($i=0; $i<count($_FILES['upload']['name']); $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
}
}
}
for($i=0; $i<count($_FILES['upload']['name']); $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
}
}
}