mi codigo es:
Código PHP:
[HIGHLIGHT="PHP"]
include 'funciones.php';
if(isset($_POST['submit'])){
if($_FILES['foto']['name'] != ""){
$allowedExts = array("jpg", "jpeg", "gif", "png", "JPG", "JPEG","GIF", "PNG");
$extension = end(explode(".", $_FILES["foto"]["name"]));
if ((($_FILES["foto"]["type"] == "image/gif")
|| ($_FILES["foto"]["type"] == "image/jpeg")
|| ($_FILES["foto"]["type"] == "image/png")
|| ($_FILES["foto"]["type"] == "image/pjpeg"))
&& in_array($extension, $allowedExts)) {
$extension = end(explode('.', $_FILES['foto']['name']));
require ('css/propios/conecta.php');
$query_maxlin=mysqli_query($conexion,"SELECT MAX(codigo) as maximo FROM articulo");
$row=mysqli_fetch_array($query_maxlin);$maximo=$row['maximo'];$maximo++;
$foto = $maximo.".".$extension;
$directorio = dirname(__FILE__).'/galeria';
move_uploaded_file($_FILES['foto']['tmp_name'], $directorio.'/'.$foto);
$original='galeria/'.$foto;
$fotodonde='fotos/'.$foto;
$consulta= mysqli_query ($conexion, "insert into articulo (codigo,subfamilia, foto,fecha_modif,orden) values ('$maximo','Lienzo','$fotodonde',now(),'$maximo')") or die ('Error al grabar la foto '.$fotodonde);
require_once('imageworkshop.php');
$capabase = new ImageWorkshop(array("imageFromPath" => $original,));
$watermarkLayer = new ImageWorkshop(array("imageFromPath" => "fotos/watermark.png",));
$capabase->resizeInPixel(800, null, true);
$watermarkLayer->resizeInPixel(240, null, true);
$watermarkLayer->opacity(60);
$capabase->addLayer(1, $watermarkLayer, 30, 30, "RT");
$dirPath = "fotos";
$filename = $foto;
$createFolders = true;
$backgroundColor = 'white';
$imageQuality = 95;
$capabase->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality);
$image = $filename->getResult();
header('Content-type: image/jpeg');
imagejpeg($image, null, 95);
} else {
$malformato = $_FILES["foto"]["type"];
header("Location: cargarImagen.php? error=noFormato&formato=$malformato");
exit;
}
} else {
header("Location: cargarImagen.php?error=noImagen");
exit;
}
} // fin del submit[/HIGHLIGHT]