max_filesize(150000); // OPTIONAL: set the max filesize of uploadable files in bytes $my_uploader->max_image_size(1600, 1600); // OPTIONAL: if you're uploading images, you can set the max pixel dimensions // UPLOAD the file if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) { $my_uploader->save_file($path, $prodID . '_tmp', $mode); if (!$my_uploader->error) { $my_uploader->resize($prodID . '_' . $size1_w . '.jpg', $size1_w, $size1_h); if($size2_w) { $my_uploader->crop($prodID . '_' . $size2_w . '.jpg', $size2_w, $size2_h, 0.4); } $my_uploader->delete_file; } } if ($my_uploader->error) { echo $my_uploader->error; } } } if(isset($_REQUEST['op'])){ $operacion = $_REQUEST['op']; } else { // no han pasado un c—digo de operaci—n. bad yuyu header('Location: articulos.php'); } // here I read the variables passed by the calling page. $id = $_REQUEST['id']; $img = $_REQUEST['img']; $conn = db_connect(); if($conn) { switch($operacion) { case "add": $num = '1'; $sql = 'SELECT galeria_imagen_name FROM edito_galeria_imagenes WHERE galeria_articulo_id = ' . $id . ' ORDER BY galeria_imagen_name DESC LIMIT 1'; $result = mysql_query($sql, $conn); if($result) { if(mysql_num_rows($result)) { $row = mysql_fetch_array($result); $num = str_replace($id . '_', '', $row['galeria_imagen_name']) + 1; } } $nuName = $id . '_' . $num; $sql = 'INSERT INTO edito_galeria_imagenes(galeria_articulo_id, galeria_imagen_name) VALUES("' . $id . '", "' . $nuName . '")'; $result = mysql_query($sql, $conn); if($result) { // subo la imagen uploadImagen($nuName, 348, 248, 108, 108); // y vuelvo a la pantalla correspondiente header('Location: articulos_edit.php?op=edit&id=' . $id); } break; case "del": $sql = 'DELETE FROM edito_galeria_imagenes WHERE galeria_imagen_name = "' . $img . '" AND galeria_articulo_id = ' . $id; mysql_query($sql, $conn); default: header('Location: articulos_edit.php?op=edit&id=' . $id); break; } } else { // no tengo conexion con el server header('Location: articulos.php'); } ?>