Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/12/2007, 01:25
Avatar de MARKWEB
MARKWEB
 
Fecha de Ingreso: septiembre-2001
Ubicación: En mi casa
Mensajes: 1.562
Antigüedad: 22 años, 7 meses
Puntos: 0
modificar codigo para insertar ruta de imagenes en base de datos

Hola amigo, tengo este codigo para subir multiples archivos a una carpeta en el servidor, pero quiero modificarlo para que solo me acepte archivos de fotos como jpg gif y png, y me cguarde la ruta en una base de datos, y que a dichas imagnes le asigne un nombre nuevo, o bien pero quiero preguntar antes si me sirve este codigo..

sino tendria que mostrale otro codigo pero me gusto este sistema

subir.php
Código PHP:
<?php
$path1
"imagenes/".$HTTP_POST_FILES['ufile']['name'][0];
$path2"imagenes/".$HTTP_POST_FILES['ufile']['name'][1];
$path3"imagenes/".$HTTP_POST_FILES['ufile']['name'][2];

copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);

echo 
"File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
echo 
"File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
echo 
"File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
echo 
"<img src=\"$path1\" width=\"150\" height=\"150\">";
echo 
"<P>";

echo 
"File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
echo 
"File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>";
echo 
"File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
echo 
"<img src=\"$path2\" width=\"150\" height=\"150\">";
echo 
"<P>";

echo 
"File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>";
echo 
"File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>";
echo 
"File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>";
echo 
"<img src=\"$path3\" width=\"150\" height=\"150\">";
?>

formulario.html
Código PHP:
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<
tr>
<
form action="subir.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<
td>
<
table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<
tr>
<
td><strong>Subir multiples archivos</strong></td>
</
tr>
<
tr>
<
td>Seleccione archivo
<input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
</
tr>
<
tr>
<
td>Seleccione archivo
<input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
</
tr>
<
tr>
<
td>Seleccione archivo
<input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
</
tr>
<
tr>
<
td align="center"><input type="submit" name="Submit" value="Subir" /></td>
</
tr>
</
table>
</
td>
</
form>
</
tr>
</
table
gracias
__________________
Un MEJOR AMIGO es como un trébol de 4 hojas, DIFÍCIL DE ENCONTRAR y ES DE BUENA SUERTE TENER UNO