B-219 Sec-55 Noida, India

Magento – Customer Profile Photo upload

To upload profile photo for customer in magento we need to follow few steps as below.

    Add a new field for profile photo(How to create new fields for customer – Check this link it will helps you).

    The above link helps you to add a new filed in DB and you need to upload that photo manually the below code will helps you to upload photos in magento.

                    if(isset($_FILES[‘logo’][‘name’]) and (file_exists($_FILES[‘logo’][‘tmp_name’])))

                      try {
                        $uploader = new Varien_File_Uploader(‘logo’);
                        $path       = Mage::getBaseDir(‘media’) . DS .’catalog/customer/logo/’;
                        $newName    = time() . $_FILES[‘logo’][‘name’];
                        $uploader->save($path, $newName);

                        // actual path of image
                        $imageUrl = $path . $newName;

                        // path of the resized image to be saved
                        // here, the resized image is saved in media/resized folder
                        $imageResized = $path . $newName;

                        // resize image only if the image file exists and the resized image file doesn’t exist
                        // the image is resized proportionally with the width/height 135px
                        if (!file_exists($imageResized)&&file_exists($imageUrl)) :
                            $imageObj = new Varien_Image($imageUrl);
                            $imageObj->resize(150, 150);

                      }catch(Exception $e) {


    After upload we need to save file name in DB.


(Visited 59 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.