upload images
am 30.05.2010 22:05:47 von Emiliano Boragina
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 =3D 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 =3D time().".jpg";
//movemos la imagen.
move_uploaded_file($_FILES['foto']['tmp_name'],
"../fotografias/".$foto);
}else{
$error =3D true;
$errormsg =3D "Formato no v=E1lido para archivo de
imagen";
}
} else {
//imagen no se pudo subir o no seleccionaron.
$error=3Dtrue;
$errormsg =3D "Error al cargar imagen: " .
$_FILES['foto']['name'];
}//fin file upload.
=09
//continuamos con el insert.
//si hay error no hay imagen.
if($error){
$foto =3D "";
}
$titulo =3D $_POST['titulo'];
$texto =3D $_POST['texto'];
$categoria =3D $_POST['categoria'];
$habilitar =3D $_POST['habilitar'];
$campos =3D "titulo,texto,foto,categoria,habilitar";
$valores =3D "'$titulo','$texto','$foto','$categoria','$habilitar'";
//nos conectamos a la bd.
$cnx =3D conectar();
$res =3D mysql_query("INSERT INTO registros ($campos)
VALUES($valores)") or die (mysql_error());
//cerramos la conexi=F3n.
mysql_close($cnx);
//mensaje de exito.
$mensaje =3D "El registro ha sido ingresado";
exit;
}
?>
If you can help me... I thanks a lot... If not... I thanks a lot anyway =
=3DD
Best regards!
------------------------------------------
Emiliano Boragina
desarrollos=A0+ comunicaci=F3n
------------------------------------------
+ 15 33 92 60 02
=BB emiliano.boragina@gmail.com
------------------------------------------
=A9 2010
------------------------------------------
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: upload images
am 30.05.2010 22:33:57 von Karl DeSaulniers
--Apple-Mail-3-591693944
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
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
--Apple-Mail-3-591693944--
Re: upload images
am 31.05.2010 01:57:46 von 3dgtech
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
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
Re: upload images
am 31.05.2010 09:27:42 von 3dgtech
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
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 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
>> 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
Re: upload images
am 31.05.2010 10:09:27 von Karl DeSaulniers
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
> 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 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
>>> 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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: upload images
am 31.05.2010 21:59:42 von Karl DeSaulniers
--Apple-Mail-1-676041384
Content-Type: text/plain;
charset=us-ascii;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
Good to hear.
Karl
Sent from losPhone
On May 31, 2010, at 2:41 PM, Emiliano Boragina
> wrote:
> Thanks a lot... this last solution is the best for me... thanks a
> lot to all!!!
>
> 2010/5/31 Karl DeSaulniers
> 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
> 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 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
> 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
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--Apple-Mail-1-676041384--