From: "Emiliano Boragina" on 30 May 2010 16:05 Hello, I want to do an Admin to upload more than one picture per clic, I must can upload one or more Pictures. This I know how is it... but I want rename each picture, not with , for example, "001" but with some function, some... thing that rename the file. I am using this: if(isset($_POST['submit'])){ $error = false; // si hay imagen. if (is_uploaded_file($_FILES['foto']['tmp_name'])) { //revisamos que sea jpg if ($_FILES['foto']['type'] == "image/jpeg" || $_FILES['foto']['type'] == "image/pjpeg"){ //nombre de la imagen $foto = time().".jpg"; //movemos la imagen. move_uploaded_file($_FILES['foto']['tmp_name'], "../fotografias/".$foto); }else{ $error = true; $errormsg = "Formato no válido para archivo de imagen"; } } else { //imagen no se pudo subir o no seleccionaron. $error=true; $errormsg = "Error al cargar imagen: " . $_FILES['foto']['name']; }//fin file upload. //continuamos con el insert. //si hay error no hay imagen. if($error){ $foto = ""; } $titulo = $_POST['titulo']; $texto = $_POST['texto']; $categoria = $_POST['categoria']; $habilitar = $_POST['habilitar']; $campos = "titulo,texto,foto,categoria,habilitar"; $valores = "'$titulo','$texto','$foto','$categoria','$habilitar'"; //nos conectamos a la bd. $cnx = conectar(); $res = mysql_query("INSERT INTO registros ($campos) VALUES($valores)") or die (mysql_error()); //cerramos la conexión. mysql_close($cnx); //mensaje de exito. $mensaje = "El registro ha sido ingresado"; exit; } ?> If you can help me... I thanks a lot... If not... I thanks a lot anyway =D Best regards! ------------------------------------------ Emiliano Boragina desarrollos + comunicación ------------------------------------------ + 15 33 92 60 02 » emiliano.boragina(a)gmail.com ------------------------------------------ © 2010 ------------------------------------------
From: Karl DeSaulniers on 30 May 2010 16:33 Try this Try assigning time() to a variable then add that to the rename. EG: if ($_FILES['foto']['type'] == "image/jpeg" || $_FILES['foto']['type'] == "image/pjpeg"){ //nombre de la imagen $timestamp = time(); //movemos la imagen. move_uploaded_file($_FILES['foto']['tmp_name'], "../fotografias/".$timestamp.".jpg"); HTH, > Karl DeSaulniers Design Drumm http://designdrumm.com
From: 3dgtech on 30 May 2010 19:57 The problem with time() is that fast servers are too fast! (you will have processed multiple files before time() changes.) Add the $i from the for loop in multiple images to the end of your filename. On May 30, 2010, at 4:33 PM, Karl DeSaulniers <karl(a)designdrumm.com> wrote: > Try this > Try assigning time() to a variable then add that to the rename. > > EG: > > if ($_FILES['foto']['type'] == "image/jpeg" || > $_FILES['foto']['type'] == "image/pjpeg"){ > //nombre de la imagen > $timestamp = time(); > //movemos la imagen. > move_uploaded_file($_FILES['foto']['tmp_name'], > "../fotografias/".$timestamp.".jpg"); > > HTH, >> > > Karl DeSaulniers > Design Drumm > http://designdrumm.com >
From: 3dgtech on 31 May 2010 03:27 It could work, but be careful using timestamp or the php equivalent - microtime since this is reliant on gettimeofday(). If naming conventions don't mandate a sterilized format I woul still recommend using a "confirmed" new variable. Just my two cents :-) Eli On May 30, 2010, at 10:04 PM, Karl DeSaulniers <karl(a)designdrumm.com> wrote: > Very good point. I did not think of that. > Change it from time() to the date + time() w/ seconds. Every second > changes. Or better yet, milliseconds. Since that is the speed the > script runs in I believe. > > That should work. Yes? > > Karl > > Sent from losPhone > > On May 30, 2010, at 6:57 PM, 3dgtech <systems(a)3dgtech.com> wrote: > >> The problem with time() is that fast servers are too fast! (you >> will have processed multiple files before time() changes.) Add the >> $i from the for loop in multiple images to the end of your filename. >> >> >> On May 30, 2010, at 4:33 PM, Karl DeSaulniers >> <karl(a)designdrumm.com> wrote: >> >>> Try this >>> Try assigning time() to a variable then add that to the rename. >>> >>> EG: >>> >>> if ($_FILES['foto']['type'] == "image/jpeg" || >>> $_FILES['foto']['type'] == "image/pjpeg"){ >>> //nombre de la imagen >>> $timestamp = time(); >>> //movemos la imagen. >>> move_uploaded_file($_FILES['foto']['tmp_name'], >>> "../fotografias/".$timestamp.".jpg"); >>> >>> HTH, >>>> >>> >>> Karl DeSaulniers >>> Design Drumm >>> http://designdrumm.com >>>
From: Karl DeSaulniers on 31 May 2010 04:09 You are probably right. The use of the $i and say "photo_".$i.".jpg" would work better. and change.. :) Karl On May 31, 2010, at 2:27 AM, 3dgtech wrote: > It could work, but be careful using timestamp or the php equivalent > - microtime since this is reliant on gettimeofday(). If naming > conventions don't mandate a sterilized format I woul still > recommend using a "confirmed" new variable. > Just my two cents :-) > Eli > > On May 30, 2010, at 10:04 PM, Karl DeSaulniers > <karl(a)designdrumm.com> wrote: > >> Very good point. I did not think of that. >> Change it from time() to the date + time() w/ seconds. Every >> second changes. Or better yet, milliseconds. Since that is the >> speed the script runs in I believe. >> >> That should work. Yes? >> >> Karl >> >> Sent from losPhone >> >> On May 30, 2010, at 6:57 PM, 3dgtech <systems(a)3dgtech.com> wrote: >> >>> The problem with time() is that fast servers are too fast! (you >>> will have processed multiple files before time() changes.) Add >>> the $i from the for loop in multiple images to the end of your >>> filename. >>> >>> >>> On May 30, 2010, at 4:33 PM, Karl DeSaulniers >>> <karl(a)designdrumm.com> wrote: >>> >>>> Try this >>>> Try assigning time() to a variable then add that to the rename. >>>> >>>> EG: >>>> >>>> if ($_FILES['foto']['type'] == "image/jpeg" || >>>> $_FILES['foto']['type'] == "image/pjpeg"){ >>>> //nombre de la imagen >>>> $timestamp = time(); >>>> //movemos la imagen. >>>> move_uploaded_file($_FILES['foto']['tmp_name'], >>>> "../fotografias/".$timestamp.".jpg"); >>>> >>>> HTH, >>>>> >>>> >>>> Karl DeSaulniers >>>> Design Drumm >>>> http://designdrumm.com >>>> > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Karl DeSaulniers Design Drumm http://designdrumm.com
|
Next
|
Last
Pages: 1 2 Prev: Fatal error: Class 'Mail' not found in Next: anyone has experience with pgslq Cybercluster 2 ? |