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);
?>