Hello, I want to do an Admin to upload more than one picture per clic, I
must can upload one or more Pictures. This I know how is it... but I want
rename each picture, not with , for example, "001" but with some function,
some... thing that rename the file. I am using this:
if(isset($_POST['submit'])){
$error = false;
// si hay imagen.
if (is_uploaded_file($_FILES['foto']['tmp_name'])) {
//revisamos que sea jpg
if ($_FILES['foto']['type'] == "image/jpeg" ||
$_FILES['foto']['type'] == "image/pjpeg"){
//nombre de la imagen
$foto = time().".jpg";
//movemos la imagen.
move_uploaded_file($_FILES['foto']['tmp_name'],
"../fotografias/".$foto);
}else{
$error = true;
$errormsg = "Formato no válido para archivo de
imagen";
}
} else {
//imagen no se pudo subir o no seleccionaron.
$error=true;
$errormsg = "Error al cargar imagen: " .
$_FILES['foto']['name'];
}//fin file upload.
//continuamos con el insert.
//si hay error no hay imagen.
if($error){
$foto = "";
}
$titulo = $_POST['titulo'];
$texto = $_POST['texto'];
$categoria = $_POST['categoria'];
$habilitar = $_POST['habilitar'];
$campos = "titulo,texto,foto,categoria,habilitar";
$valores = "'$titulo','$texto','$foto','$categoria','$habilitar'";
//nos conectamos a la bd.
$cnx = conectar();
$res = mysql_query("INSERT INTO registros ($campos)
VALUES($valores)") or die (mysql_error());
//cerramos la conexión.
mysql_close($cnx);
//mensaje de exito.
$mensaje = "El registro ha sido ingresado";
exit;
}
?>
If you can help me... I thanks a lot... If not... I thanks a lot anyway =D
Best regards!
------------------------------------------
Emiliano Boragina
desarrollos + comunicación
------------------------------------------
+ 15 33 92 60 02
» [email protected]
------------------------------------------
© 2010
------------------------------------------
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php