Foros del Web » Programando para Internet » PHP »

Ayuda upload de imagenes

Estas en el tema de Ayuda upload de imagenes en el foro de PHP en Foros del Web. Buenas, tengo un script de upload de imagenes, pero no se graban en mi bd. Por favor alguien quien me ayude. mysql_query($insert); $item_id = mysql_insert_id(); ...
  #1 (permalink)  
Antiguo 03/11/2004, 14:49
 
Fecha de Ingreso: septiembre-2004
Mensajes: 106
Antigüedad: 13 años, 2 meses
Puntos: 0
Ayuda upload de imagenes

Buenas,
tengo un script de upload de imagenes, pero no se graban en mi bd.
Por favor alguien quien me ayude.

mysql_query($insert);

$item_id = mysql_insert_id();

if(isset($HTTP_POST_FILES))
{
if(is_uploaded_file($HTTP_POST_FILES["thumbnail"]["tmp_name"]))
{
$file_handle = fopen($HTTP_POST_FILES["thumbnail"]["tmp_name"], "rb");
$thumbnail = $HTTP_POST_FILES["thumbnail"]["name"];
$file_bytes = addslashes(fread($file_handle,
filesize($HTTP_POST_FILES["thumbnail"]["tmp_name"])));

$update = "update items set " .
"thumbnail = '" . $file_bytes . "' " .
"where id = " . $item_id;
mysql_query($update);

unlink($HTTP_POST_FILES["thumbnail"]["tmp_name"]);
}

if(is_uploaded_file($HTTP_POST_FILES["image"]["tmp_name"]))
{
$file_handle = fopen($HTTP_POST_FILES["image"]["tmp_name"], "rb");
$image = $HTTP_POST_FILES["image"]["name"];
$file_bytes = addslashes(fread($file_handle,
filesize($HTTP_POST_FILES["image"]["tmp_name"])));

$update = "update items set " .
"image = '" . $file_bytes . "' " .
"where id = " . $item_id;
mysql_query($update);

unlink($HTTP_POST_FILES["image"]["tmp_name"]);
}
}
}

$select = "select id from items order by ordre";
$ids = mysql_query($select);
while(($id = mysql_fetch_assoc($ids)) && $isLogged == true)
{
$item_id = $HTTP_POST_VARS["id_" . $id["id"]];
//If the item was modified, save it.
if($item_id != "" && $item_id > 0)
{
$name = $HTTP_POST_VARS["name_" . $id["id"]];
$price = $HTTP_POST_VARS["price_" . $id["id"]];
$summary = $HTTP_POST_VARS["summary_" . $id["id"]];
$description = $HTTP_POST_VARS["description_" . $id["id"]];
$ordre = $HTTP_POST_VARS["ordre_" . $id["id"]];

$update = "update items set " .
"name = '" . $name . "', " .
"price = " . $price . ", " .
"summary = '" . $summary . "', " .
"description = '" . $description . "', " .
"ordre = " . $ordre . " " .
"where id = " . $item_id;

mysql_query($update);

//Were any files uploaded?
if(isset($HTTP_POST_FILES))
{
if(is_uploaded_file($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"]))
{
$file_handle = fopen($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"], "rb");
$thumbnail = $HTTP_POST_FILES["thumbnail_" . $item_id]["name"];
$file_bytes = addslashes(fread($file_handle,
filesize($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"])));

$update = "update items set " .
"thumbnail = '" . $file_bytes . "' " .
"where id = " . $item_id;
mysql_query($update);

unlink($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"]);
}

if(is_uploaded_file($HTTP_POST_FILES["image_" . $item_id]["tmp_name"]))
{
$file_handle = fopen($HTTP_POST_FILES["image_" . $item_id]["tmp_name"], "rb");
$image = $HTTP_POST_FILES["image_" . $item_id]["name"];
$file_bytes = addslashes(fread($file_handle,
filesize($HTTP_POST_FILES["image_" . $item_id]["tmp_name"])));

$update = "update items set " .
"image = '" . $file_bytes . "' " .
"where id = " . $item_id;
mysql_query($update);

unlink($HTTP_POST_FILES["image_" . $item_id]["tmp_name"]);
}
}
}

//Delete items.
if($item_id != "" && $item_id < 0)
{
$delete = "delete from items where id = " . (-$item_id);

mysql_query($delete);

unlink("./images/item_" . (-$item_id) . "_thumbnail.jpg");
unlink("./images/item_" . (-$item_id) . "_image.jpg");
}
}

$select = "select * from items order by ordre";
$items = mysql_query($select);
?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:26.