![sonriente](http://static.forosdelweb.com/fdwtheme/images/smilies/smile.png)
Estoy haciendo una pág en DreamWeaver MX 2004 y he "copiado" y modificado de forma muy simple un script q encontré en la red para subir archivos.
Les pongo la pág subir_archivo.php y la pág upload.php para ver si me pueden ayudar, please ;)
---subir_archivos.php-----------------------------------------------------------------------------
<form action="/upload.php" method="POST" enctype="multipart/form-data" name="subir" id="subir">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td><input name="image1" type="file" id="image1"></td>
</tr>
<tr>
<td> </td>
<td><input name="image2" type="file" id="image2"></td>
</tr>
<tr>
<td> </td>
<td><input name="image3" type="file" id="image3"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Subir archivo"></td>
<td> </td>
</tr>
</table>
<p align="left"><br>
</p>
<p align="left"> </p>
<p align="left">
<input name="MM_insert" type="hidden" id="MM_insert" value="insertar">
</p>
</form>
---y ahora el upload.php--------------------------------------------------------------------------
<EN EL ENCABEZADO>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "/upload.php" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clientes (image1, image2, image3) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['image1'], "text"),
GetSQLValueString($_POST['image2'], "text"),
GetSQLValueString($_POST['image3'], "text"));
mysql_select_db($database_base, $base);
$Result1 = mysql_query($insertSQL, $base) or die(mysql_error());
$insertGoTo = "/upload.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<EN EL BODY>
<?php
$directorio = $_SERVER['DOCUMENT_ROOT'].'/images/';
if (move_uploaded_file($_FILES['image1']['tmp_name'], $directorio . $_FILES['image1']['name']))
{
print "Imagen1 subida con éxito.";
}
else
{
print "Error al intentar subir la imagen.";
}
?>
<?php
$directorio = $_SERVER['DOCUMENT_ROOT'].'/images/';
if (move_uploaded_file($_FILES['image2']['tmp_name'], $directorio . $_FILES['image2']['name']))
{
print "Imagen2 subida con éxito.";
}
else
{
print "Error al intentar subir la imagen.";
}
?>
<?php
$directorio = $_SERVER['DOCUMENT_ROOT'].'/images/';
if (move_uploaded_file($_FILES['image3']['tmp_name'], $directorio . $_FILES['image3']['name']))
{
print "La imagen3 fue subida con éxito.";
}
else
{
print "Error al intentar subir la imagen.";
}
?>
Sé q es muy poco profesional o "cutre", pero me sirve para subir archivos (imágenes en mi caso) al servidor; siempre q el comando "mm_insert" no tengan el mismo nombre ("insertar" y "form1").
El problema es q no sé q hacer para q se inserten los datos además en la base de datos. O sea, si alguien sube una imagen q además se inserte en la base de datos el nombre de la imagen sólamente. Pongo un ejemplo x si m explico mal:
--- Alguien quiere subir la foto "colinas azules.jpg" (es d las q vienen en Windows;) q se encuentra en C:/documents and settings/mis documentos/mis imágenes. La ruta sería lógicamente "C:/documents and settings/mis documentos/mis imágenes/colinas azules.jpg". Pues bien, lo que me gustaría es q se almacenase el "colinas azules.jpg" dentro del campo "image1" de la tabla "clientes" de la base de datos "base". La conexión es "base.php".
Estaría muy agradecida a cualquiera q aportase alguna idea.
Montón de gracias a tod@s y besitos ;)
![sonriente](http://static.forosdelweb.com/fdwtheme/images/smilies/smile.png)