如何将输入文件附加到magento中的产品自定义选项?

I need to take input file and want to attach that file while adding product to cart programmatically. i want to attach file like photo to sale order while adding to cart

How would i achieve that? below is what i do for normal text field. similarly i want for input type file.

$request = new Varien_Object(array(
'qty'=>1,
'options' => array(3=>'test') // 3 is id of custom option
));

    $cart = Mage::getModel('checkout/cart');
    $cart->init();
    $cart->addProduct($my_product, $request);

    $cart->addProduct($sub_product,$request);
    $cart->save();
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);

Help me Out

Magento includes a file type custom option type that can be assigned to products.

  1. Create or edit an existing product
  2. Click the Custom Options tab on the left
  3. Click the Add New Option button
  4. Select File for the Input Type

File custom options type

When set correctly, a field will become available on the Product View page for the customer to upload a file.