Programmatically add upsell products to a product in magento
devm.com.np
<?php
$productId 
Mage::getModel('catalog/product')->getIdBySku('sku');
$product Mage::getModel('catalog/product')->load($productId);

$productId1 1;
$productId2 2;

$upsellLinks = array();

$upsellLinks[$productId1] = array('position'=>'') ;
$upsellLinks[$productId2] = array('position'=>'') ;

$product->setUpSellLinkData($upsellLinks);
?>