2
My code is currently doing its role well by uploading and putting the watermark on the upload images, however I would like to be storing the names of all images in the database.
$idnoticia = $_GET['idnoticia'];
$watermark = imagecreatefrompng('watermark.png');
$watermark_x = imagesx($watermark);
$watermark_y = imagesy($watermark);
$dir = "../img/$idnoticia/";
foreach($_FILES['files']['tmp_name'] as $index => $file) {
$image = imagecreatefromjpeg($file);
imagecopy($image, $watermark, round(imagesx($image) / 1) - round($watermark_x / 1), round(imagesy($image) / 1) - round($watermark_y / 1), 0, 0, $watermark_x, $watermark_y);
imagejpeg($image, $dir . preg_replace('/.jpeg|.jpg/i', '', $_FILES['files']['name'][$index]) . '_wm.jpg');
imagedestroy($image);
}
imagedestroy($watermark);
echo "Envio Completado!";
$sqlInsert = 'UPDATE noticias SET galeria = "$image" WHERE idnoticia = "$idnoticia';
$stmt = DB::prepare($sqlInsert2);
$stmt->bindParam("galeria", $image);
$stmt->execute();
I would like to store the image names in the field galeria
like (img1.jpg, img2.jpg, img3.jpg), placing a delimiter for when to display facilitate.
It is possible?