Jump to content

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';
	}
?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.