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
2417
Visitas
4
Resp
Por mavericka3 hace 10 años
Novice
Respuesta #1
Buenas pon el código que tienes en process.php Saludos
0
Puntos
Por alber hace 10 años
Admin
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_Phpres['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 10 años
Novice
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 10 años
Admin
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 10 años
Novice
Para comentar Inicia sesión o Regístrate
Phpres 2025@ All rights reserved.
Utilizamos cookies para mejorar la navegación en el sitio. Más información Aceptar