Bienvenido a datoweb.com!! En este foro podrás encontrar ayuda sobre diseño y desarrollo web en general. Si quieres formar parte de esta comunidad para pedir ayuda o colaborar ayudando a otros usuarios del foro solo tienes que registrarte desde el siguiente enlace: Registrarse en el Foro

Problema con Notice: Undefined index:

Hola buenas tardes estoy realizando un curso de Dato web y me estoy encontrando con varios problemas y por más que busco por internet no los logro resolver.

resulta que tengo este codigo para subir una imagen:

//Subir imagen
$imagen_nombre = isset($_FILES['imagen1']['name']);
move_uploaded_file ($_FILES['imagen1']['tmp_name'], "../anuncios/img/upload/".$imagen_nombre);

al subir un un post con una imagen incluida me marca el siguiente error:

Notice: Undefined index: tmp_name in C:\xampp\htdocs\mil_pueblos\includes\procces.php on line 44

la imagen se sube y todo pero me marca esto en la pantalla de procces.

0
Puntos
2465
Visitas
4
Resp
Por Mavericka3 hace 106 meses
Principiante
Respuesta #1
Buenas pon el código que tienes en process.php Saludos
0
Puntos
Por alber hace 106 meses
Administrador
Respuesta #2
Hola gracias alber por contestar el codigo es el siguiente:

<?php require_once('../Connections/conexion.php');

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$_SESSION['MM_iduser'] = $row_datoweb['id'];
//$_FILES['imagen1']['name']= $row_Subir_anuncio['imagen'];


//Subir imagen
$nombre_imagen = isset($_FILES['imagen1']['name']);
move_uploaded_file ($_FILES['imagen1']['tmp_name'], "../anuncios/img/upload/".$nombre_imagen);


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_agr_anuncios")) {
$insertSQL = sprintf("INSERT INTO z_post_anuncios (titulo, mensaje, autor, imagen) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['mensaje'], "text"),
GetSQLValueString($_SESSION['MM_iduser'], "int"),
GetSQLValueString($nombre_imagen, "text"));

mysql_select_db($database_conexion, $conexion);
$Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());

$insertGoTo = "http://localhost/mil_pueblos/includes/procces.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

?>
0
Puntos
Por Mavericka3 hace 106 meses
Principiante
Respuesta #3
ok, lo que pasa es que esta variable la tienes mal
$insertGoTo = "http://localhost/mil_pueblos/includes/procces.php";
lo que estas haciendo después de subir la foto es redireccionar al mismo archivo (process.php) por eso te sale el error de que la variable esta vacía

cambia esa linea por esta
$insertGoTo = "http://localhost/mil_pueblos/index.php";
donde eh puesto index puedes poner otra ruta de una pagina existente dentro de tu proyecto

saludos!
0
Puntos
Por alber hace 106 meses
Administrador
Respuesta #4
hola albert!!!!!
es verdad tenias razón. Muchisimas gracias por haberme ayudado. Me estaba volviendo loco.
Muchas gracias de nuevo de verdad.
0
Puntos
Por Mavericka3 hace 106 meses
Principiante
Compartir en facebook
Compartir en twitter
Compartir
Para comentar Inicia sesión o Registrate