if you want to add file upload for client / product. just create a related attribute for this, and in the admin panel you will find an option and work correctly, and for the interface just create an input file. upload it through the magento file downloader to any directory and just save the file path in the attribute. My code for the client file attribute for reference:
<label for="certificate"><?php echo $this->__('Re-Sale Certificate') ?></label>
<div class="input-box">
<input type="file" name="designer_certificate" title="<?php echo $this->__('certificate') ?>" id="designer_certificate" />
</div>
installer for file attribute
$installer = $this;
$installer->startSetup();
$installer->removeAttribute('customer', 'designer_certificate');
$installer->addAttribute("customer", "designer_certificate", array(
"type" => "varchar",
"backend" => "",
"label" => "Designer Certificate",
"input" => "file",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "designer_certificate");
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();
$installer->endSetup();
configurations:
<global>
....
<resources>
<designercertificate_setup>
<setup>
<module>Renegade_Account</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</designercertificate_setup>
<designercertificate_write>
<connection>
<use>core_write</use>
</connection>
</designercertificate_write>
<designercertificate_read>
<connection>
<use>core_read</use>
</connection>
</designercertificate_read>
</resources>
....
</global>
Now download the file and just save as
.....
$path = Mage::getBaseDir('media') . DS .'customer'. DS . 'designer-certificates' . DS;
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$filename = str_replace(' ', '_', trim($_FILES['designer_certificate']['name']));
Add a comment to this line
$uploader->save($path, $filename);
$file = "/designer-certificates/" . $filename;
$customer->setDesignerCertificate($file);
.....
the file must be saved in the media, the client folder for the client file attribute, if you want to use the built-in functions.