how to add customer photo registration profile page in magento

Share

how to add customer photo in magento registration – profile page

I have to add 3 image upload box as per my client demand. First one was his photo , second one was his credit card front side scan copy and third one was credit card back side scan copy. He did it for his customer verification.
Now i will explain you how i fix it.
At first change the registration and edit form type to enctype=”multipart/form-data”
Add the following code in register.phtml to add photo field in database
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);
$attr2 = array (
‘position’ => 1,
‘is_required’=>0 /* 0 if you want it to be a required field, 1 if not. Also, if required, add this class to the occupation input box on register.phtml class=”required-entry input-text” */
);
$setup->addAttribute(’1′, ‘photo’, $attr2);

app/design/frontend/default/yourtheme/template/customer/form/register.phtml


app/design/frontend/default/yourtheme/template/customer/form/edit.phtml

Also add the new file type field into the above two forms. Add the code
Then add the new filed say name “photo” into the following file.
app/code/core/Mage/Customer/Model/Entity/Setup.php file.

‘photo’ => array(
‘label’         => ‘Photo1′,
‘required’      => false,
‘sort_order’    => 61,
),

Now update the following file with the photo field
app/code/core/Mage/Customer/etc/config.xml

<photo1><create>1</create><update>1</update></photo1>

Now modify the following file and wrote your code for uploading image :
app/code/core/Mage/Customer/controllers/AccountController.php

In public function createPostAction() at the following lines.. at 274 line where checking form post

//Added by zahid for file upload
$logoName = ”;
if (isset($_FILES['photo']['name']) && $_FILES['photo']['name'] != ”) {
try {
$uploader = new Varien_File_Uploader(‘photo1′);
$uploader->setAllowedExtensions(array(‘jpg’,’jpeg’,’gif’,’png’));
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$path = Mage::getBaseDir(‘media’) . DS.’customer’.DS;
$logoName = $_FILES['photo']['name'];
$uploader->save($path, $logoName);

} catch (Exception $e) {

}
}

if (!$customer = Mage::registry(‘current_customer’)) {

$customer = Mage::getModel(‘customer/customer’)
->setFirstname($this->getRequest()->getPost(‘firstname’))
->setLastname($this->getRequest()->getPost(‘lastname’))
->setEmail($this->getRequest()->getPost(‘email’))
->setPhoto($logoName) //Add this
->setPassword($this->getRequest()->getPost(‘password’))
->setConfirmation($this->getRequest()->getPost(‘confirmation’))
->setId(null);
}

Comments are closed.