Ver Mensaje Individual
  #10 (permalink)  
Antiguo 06/05/2009, 10:05
Avatar de Dragon_Mandarin
Dragon_Mandarin
 
Fecha de Ingreso: marzo-2005
Ubicación: Santiago de Chile
Mensajes: 231
Antigüedad: 19 años, 1 mes
Puntos: 14
Cita:
Iniciado por harvestmoon Ver Mensaje
para servirte cualquier cosa aki esta el foro para echarte una mano
saludines!!
y suerte en todo!

Gracias, amigo!

Ahora estoy en el rollo de hacer la miniatura cuando publico todo. Así es que, si me da mucha guerra, les pido ayuda, nuevamente.

Hasta pronto

No me ha ido bien con la creación de las miniaturas (thumbs) desde el fomulario para agregar noticias. Como ya saben -y gracias a harvestmoon-, logré que el formulario inyectara el nombre de la foto en la base de datos. Pero ahora necesito generar la miniatura.

El formulario:

Código PHP:
<?php
//Subimos le imagen a la carpeta, en este caso "fotos"
if (isset($_POST['enviar'])) { 
    if(
is_uploaded_file($_FILES['notFoto']['tmp_name'])) { // verifica haya sido cargado el archivo
  
$ruta"../fotos/".$_FILES['notFoto']['name']; // Se guardaría dentro de "fotos" con el nombre original
// $ruta= "carpeta/nuevo_nombre.jpg"; si también se quiere renombrar
 
move_uploaded_file($_FILES['notFoto']['tmp_name'], $ruta);
        if(
move_uploaded_file($_FILES['notFoto']['tmp_name'], $_FILES['notFoto']['name'])) { // se coloca en su lugar final
             
echo "<b>Upload exitoso!. Datos:</b><br>";
            echo 
"Nombre: <i><a href=\"".$_FILES['notFoto']['name']."\">".$_FILES['notFoto']['name']."</a></i><br><br>";
            echo 
"Tipo MIME: <i>".$_FILES['notFoto']['type']."</i><br>";
                    echo 
"Peso: <i>".$_FILES['notFoto']['size']." bytes</i><br>";
                        echo 
"<br><hr><br>";
        }
    }
 
// A continuación el formulario
}
// incluimos el archivo de conexion
include ('db-cnx.php');
// recibimos el formulario
if(isset($_POST['enviar']) && $_POST['enviar'] == 'Enviar'){
    
// comprobamos que el formulario no envie campos vacios
    
if(!empty($_POST['notTitulo']) && $_POST['notTexto'] && $_POST['catCategoria'] && $_POST['fecha']){
        
// creamos las variables y les asignamos los valores a insertar
        
$notTitulo $_POST['notTitulo'];
        
$notTexto $_POST['notTexto'];
        
$notFoto $ruta$_FILES['notFoto']['name'];
        echo 
$ruta
        
$fecha $_POST['fecha'];
        
$catCategoria $_POST['catCategoria'];
        
// hacemos el INSERT en la BD
        
$sqlInsertNot mysql_query("INSERT INTO sn_noticias
                         (notTitulo, notTexto, notFoto, catCategoria, fecha)
                         VALUES ('$notTitulo', '$notTexto','$notFoto', '$catCategoria', '$fecha')"
,
                         
$db_link) or die(mysql_error());
        
// enviamos un mensaje de exito
        
echo "<b>Los datos fueron guardados correctamente</b>&nbsp; | <a href=\"index.php\">Volver a la Administración</a>";
    }else{
        
// si el formulario envia algun campo vacio
        // enviamos un mensaje de error
        
echo "Debe llenar todos los campos del formulario<br />";
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<title>Agregar Noticia</title>
<LINK HREF="style.css" REL="stylesheet" TYPE="text/css">
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
 tinyMCE.init({
  // General options
  mode : "textareas",
  theme : "advanced",
  plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
  // Theme options
  theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
  theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
  theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
  theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "bottom",
  theme_advanced_resizing : true,
  // Example content CSS (should be your site CSS)
  content_css : "css/content.css",
  // Drop lists for link/image/media/template dialogs
  template_external_list_url : "lists/template_list.js",
  external_link_list_url : "lists/link_list.js",
  external_image_list_url : "lists/image_list.js",
  media_external_list_url : "lists/media_list.js",
  // Replace values for the template plugin
  template_replace_values : {
   username : "Some User",
   staffid : "991234"
  }
 });
</script>
<!-- /TinyMCE -->
<style type="text/css">
<!--
@import url("css-add-noti.css");
body {
 margin-left: 20px;
 margin-top: 15px;
}
-->
</style>
</head>
<body text="#17334a" vlink="#000040" alink="#000040" link="#000040" bgcolor="#ffffff" background="images/index_bg.gif">
<div class="ts-1">
  <!-- el formulario -->
  <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="noticia">
    <p>Agregar las noticias preferible en formato HTML     </p>
    <p>T&iacute;tulo de la Noticia<br />
      <input type="text" name="notTitulo" size="70" />
    </p>
    <p>
      Texto de la Noticia<br />
      <textarea name="notTexto" rows="20" cols="90"></textarea>
      <br />
      <input name="fecha" type="hidden" value="<?=date("Y-m-d"); ?> <?=date("h:i:s");?>" />
      <br />
      <label>
        <input type="file" name="notFoto" id="notFoto" />
      </label>
      <br />
    </p>
    <p>
      Categor&iacute;a<br />
      <select name="catCategoria">
        <option value="">Escoger de la Lista</option>
        <?php
    
// asignamos una categoria a la noticia
    // mediante un select
    
$sqlQueryCat mysql_query("SELECT * FROM sn_categorias"$db_link)
                                or die(
mysql_error);
    
// creamos un bucle while
    // que nos muestre todas las categorias
    // que tenemos guardadas en la BD
    
while($rowCat mysql_fetch_array($sqlQueryCat)){ ?>
<!-- echo "<option value='$rowCat[cat_ID]'>$rowCat[catCategoria] - $rowCat[cat_ID]</option>";-->
<option value='<?=$rowCat[catCategoria]; ?>'><?=$rowCat[catCategoria]; ?></option>
    <? }    ?>
      </select>
      <br />
      <br />
  <input type="submit" name="enviar" value="Enviar" />   
</form>
</body>
</html>
Espero puedan ayudarme, nuevamente.

Gracias!

Última edición por GatorV; 06/05/2009 a las 14:23