Foros del Web » Programando para Internet » PHP »

Problema con move_uploaded_file()

Estas en el tema de Problema con move_uploaded_file() en el foro de PHP en Foros del Web. Hola, aca les traigo un problema que me surgio y no puedo encontrarle solucion. Cuando quiero subir una imagen me tira este error en el ...
  #1 (permalink)  
Antiguo 09/04/2013, 21:53
 
Fecha de Ingreso: octubre-2011
Mensajes: 17
Antigüedad: 12 años, 6 meses
Puntos: 0
Problema con move_uploaded_file()

Hola, aca les traigo un problema que me surgio y no puedo encontrarle solucion. Cuando quiero subir una imagen me tira este error en el navegador:

Warning: Wrong parameter count for move_uploaded_file() in C:\wamp\www\prueba\_admin\gestionimagen.php on line 14

En gestionimagen.php tengo este codigo:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]">
<html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]">
<link href="../css/estiloadmin.css" rel="stylesheet" type="text/css" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Subir imagen</title>
</head>
<body>
<?php if ((isset($_POST["enviado"])) && ($_POST["enviado"] == "form1")) {
$nombre_archivo = $_FILES['userfile']['name'];

move_uploaded_file($_FILES['userfile']['tmp_name'], "../imagen/slider/", $nombre_archivo);

?>
<script>
opener.document.form1.<?php echo $_POST["enviado"]; ?>.value="<?php echo $nombre_archivo; ?>"; self.close();
</script>
<?php
}
else
{?>
<form action="gestionimagen.php" method="post" enctype="multipart/form-data" id="form1" name="form1">
<p>
<input name="userfile" type="file" />
</p>
<p>
<a class="button" href="javascript:document.form1.submit();"><span>S ubir Imagen</span></a>

</p><input name="nombrecampo" type="hidden" value="<?php echo $_GET["campo"]; ?>" />
<input type="hidden" name="enviado" value="form1" />
</form>
<?php }?>
</body>
</html>

Y en slider_add.php tengo este codigo:

<?php require_once('../Connections/conexionprueba.php'); ?>
<?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']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tblslider (idContador, strimagenGrande, strimagenPequena, strTitulo, strSubtitulo, strMenu, strLink, IntOrden, IntEstado) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['idContador'], "int"),
GetSQLValueString($_POST['strimagenGrande'], "text"),
GetSQLValueString($_POST['strimagenPequena'], "text"),
GetSQLValueString($_POST['strTitulo'], "text"),
GetSQLValueString($_POST['strSubtitulo'], "text"),
GetSQLValueString($_POST['strMenu'], "text"),
GetSQLValueString($_POST['strLink'], "text"),
GetSQLValueString($_POST['IntOrden'], "int"),
GetSQLValueString($_POST['IntEstado'], "int"));
mysql_select_db($database_conexionprueba, $conexionprueba);
$Result1 = mysql_query($insertSQL, $conexionprueba) or die(mysql_error());
$insertGoTo = "slider_lista.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]">
<html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]">

<title>Administracion AyZWeb</title>

<script>
function subirimagen(nombrecampo)
{
self.name = 'opener';
remote = open('gestionimagen.php?campo='+nombrecampo, 'remote', 'with=400, height=150, location=no, scrollbars=yes, menubars=no, toolbars=no, resizable=yes, fullscreen=no, status=yes');
remote.focus();
}
</script>


<h1>A&ntilde;adir Publicidad</h1>
<p>&nbsp;</p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Imagen Grande (738x250px):</td>
<td><input type="text" name="strimagenGrande" value="" size="32" /><input type="button" name="botton" id="botton" value="subir imagen" onclick="javascript:subirimagen('strimagenGrande') ;"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Imagen Peque&ntilde;a (80x50px):</td>
<td><input type="text" name="strimagenPequena" value="" size="32" /><input type="button" name="botton2" id="botton2" value="subir imagen" onclick="javascript:subirimagen('strimagenPequena' );"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Titulo:</td>
<td><input type="text" name="strTitulo" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Subtitulo:</td>
<td><input type="text" name="strSubtitulo" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Menu:</td>
<td><input type="text" name="strMenu" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Link:</td>
<td><input type="text" name="strLink" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Orden:</td>
<td><input type="text" name="IntOrden" value="" size="5" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Estado:</td>
<td><label for="IntEstado"></label>
<select name="IntEstado" id="IntEstado">
<option value="1">Activo</option>
<option value="0">Desactivado</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td>
<a class="button" href="javascript:document.form1.submit();"><span>I nsertar Slider</span></a>
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>

</html>

Agradezco si me pudieran ayudar con esto. Saludos

Última edición por Ch3Ch0; 09/04/2013 a las 22:15
  #2 (permalink)  
Antiguo 10/04/2013, 05:11
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: Problema con move_uploaded_file()

Cita:
Warning: Wrong parameter count for move_uploaded_file() in C:\wamp\www\prueba\_admin\gestionimagen.php on line 14
Traducción libre del aviso:

Error en el numero de parametros.

En el manual vemos

move_uploaded_file

Cita:
Parámetros

filename
El nombre de archivo del archivo subido.

destination
El destino del archivo movido.
Luego cambia

Código PHP:
Ver original
  1. move_uploaded_file($_FILES['userfile']['tmp_name'], "../imagen/slider/", $nombre_archivo);

por

Código PHP:
Ver original
  1. move_uploaded_file($_FILES['userfile']['tmp_name'], "../imagen/slider/".$nombre_archivo);

con

Código PHP:
Ver original
  1. echo "<pre>";
  2. print_r($_FILES);
  3. echo "</pre>"

verás exactamente que tienes en le array...
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.
  #3 (permalink)  
Antiguo 10/04/2013, 08:22
 
Fecha de Ingreso: octubre-2011
Mensajes: 17
Antigüedad: 12 años, 6 meses
Puntos: 0
Respuesta: Problema con move_uploaded_file()

Solucionado! Muchas gracias Quim! Un abrazo!

Etiquetas: diseño-web, html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:25.