Me interesaría introducir un número aleatorio para evitar duplicidad en archivos subidos al servidor.
¿Dónde tengo que colocarlo? ""substr(md5(uniqid(rand())),0,6)""
Intento con este, pero puede ser otro.
Muchas gracias.
Código PHP:
Ver original
<?php require_once('../../Connections/contactos.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { } $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": break; case "double": break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $query_Recordset1 = "SELECT * FROM contactos"; ?> ....... <? $nombre=$_POST[nombre]; $apellido=$_POST[apellido]; $ciudad=$_POST[ciudad]; $provincia=$_POST[provincia]; $web=$_POST[web]; $tituloanuncio=$_POST[tituloanuncio]; $precio=$_POST[precio]; $foto1 = $_FILES['foto1']['name']; // "directorio" es el directorio donde vas a subir la imagen. mysql_query("insert into contactos(foto1 , nombre , apellido , ciudad , provincia , web , tituloanuncio , precio) values('/imagenes/$foto1','$nombre','$apellido','$ciudad','$provincia','$web','$tituloanuncio','$precio')",$db) or die("La clave introducida, ya existe. Elige otra"); //ahora subamos la imagen, "directorio" es el directorio donde la vas a subir. ?> </h1> <!-- end #mainContent --></div> <!-- Este elemento de eliminación siempre debe ir inmediatamente después del div #mainContent para forzar al div #container a que contenga todos los elementos flotantes hijos --><br class="clearfloat" /> <div id="footer"> <p>Pie</p> <!-- end #footer --></div> <!-- end #container --></div> </body> </html> <?php ?>