Programatically upload/link images and attatch to Ubercart's product node? One of the things my Ubercart module needs to be able to do is programatically upload or link (this being preferred as it means I don't have to mirror it) an image and attach to Ubercart's product node. The user will give me some information, and my module will fill in the name, description, and product image. The product image is a big hurdle which I have no idea how to conquer.

The core Ubercart module product has a dependency on Drupal's core Image module, which is where I'm assuming is handling all the images. I thought I could learn how to do it by looking at the product module's code, but I'm having trouble wading through and understanding the thousands of lines of code. I'm not even sure of any other module that does something similar to what I'm doing, so I'm out of example code.

Does anyone know of a way to accomplish what I'm wanting to accomplish?
Ubercart already has the option of a predefined cck imagedfield, where do you plan on getting the correct image programatically? I remember using a default imagefield image before in the field settings. 

Have a search for creating ubercart products programatically, its a fairly common thing as people import products from other dbs and excel files etc.

Here is a start, it all depends on where your data is coming from;

&lt;?php
function MYMODULE_createnode() {

global $user;
if (isset(

$_POST['values_from_form']))
  {
    $values['nid'] = intval(check_plain($_POST['nid'])); 
    $values['title'] = check_plain($_POST['title']);
    $values['type'] = 'product'; //uc node content type
    $values['body'] = $_POST['body']; 
    $values['name'] = $user-&gt;name;
    $values['uid'] = $user-&gt;uid;
    $values['field_cck_field'][0]['value'] = $_POST['cck_field']; // Custom CCK field example for whatever it was you were wanting to do
    $values['status'] = 1;


    $node = node_submit($values);

    node_save($node);

    }
}
?&gt;