Jump to content

How to upload multiples images and strore link on database


carlitoway

Recommended Posts

I have this code and it works perfect with one image, but I need to upload more images (10) , can someone please help me with this problem...???

 

 

this is my Code

<!DOCTYPE html>
<html>
<body>
	<h2>Subir imagen</h2>
		
	<form method="POST" enctype="multipart/form-data" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" >
		<input type="file" name="imagen"/>
		<input name="enviar" type="submit" value="Enviar"/>
	</form>
</body>
</html>
<?php
$host = "localhost";
$user = "root";
$pw = "";
$bd = "base";

$conexion=mysql_connect('localhost','root','') or die ('no hay conexion a la base de datos');
$db=mysql_select_db('base',$conexion) or die ('no existe la base de datos');

$RutaServidor='imagenes-de-usuarios';
$RutaTemporal=$_FILES['imagen']['tmp_name'];
$NombreImagen=$_FILES['imagen']['name'];
$SizeImagen=$_FILES['imagen']['size'];
$rutaDestino=$RutaServidor.'/'.$SizeImagen.$NombreImagen;
move_uploaded_file($RutaTemporal,$rutaDestino);

$sql="INSERT INTO imagenes (ruta) values ('".$rutaDestino."')";
$respuesta=mysql_query($sql,$conexion);
if ($respuesta){
	echo '	<div class="subido">
		<h2>Imagen guardada con exito</h2>
		<br>
		<h2 class="close-window2">Continuar</h2>
		</div>';
		}else 
		{
		echo 'no se puedo guardar la imagen intentelo de nuevo';
	}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.