2

We are Providing product personalization feature [ users can upload image from product view page & buy the product].

here user can upload any number of images by clicking upload image button here

enter image description here

1) click upload image button = > click +Upload new image in pop up = > upload image from local system = > click on "Add Image" , than again if we try same steps, we will get an errors as below , means 1st time its working fine, but 2nd time show error.

enter image description here

But only in Mozilla Firefox 2nd time also its working fine.

AjaxController.php

public function addImageAction()
    {
        $response = array();
        if(isset($_FILES['new_image']['name']) && (file_exists($_FILES['new_image']['tmp_name']))) {
            $uploader = $this->setUpUploader();
            $path = Mage::getBaseDir('media') . DS . 'custom_product_preview' . DS . 'quote' . DS;
            try 
            {
                $uploader->save($path, preg_replace('/[^A-Za-z\d\.]/','_',$_FILES['new_image']['name']));
                $filename = $uploader->getUploadedFileName();

                $filename = $this->_convertToImg($filename);

                if(getimagesize($path.$filename)!==false)
                {
                    $response['src'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'custom_product_preview/quote/'.$filename;
                    $response['error'] = 0;
                }
                else
                {
                    $response['error'] = Mage::helper('aitcg')->__('Image file is empty or corrupt');
                }
            }
            catch (Exception $e)
            {
                $response['error'] = $e->getMessage();
            }

        }
        else
        {
            $response['error'] = Mage::helper('aitcg')->__('Something went wrong. Please try again.');
        }

        $this->_setBodyJson($response); 
    }

System.log

enter image description here

Edit : seems above system.log error is not related to this issue

edit 2 : console

enter image description here

Edit 3

loaded : function(id) {
        var d, 
            i = $(id);
        if (i && i.contentDocument) {
            d = i.contentDocument;
        } else if (i && i.contentWindow) {
            d = i.contentWindow.document;
        } else {
            d = window.frames[id].document;
        }


        with($(this.file_id)) {
            disabled = false;
            value = "";
        }

        if (typeof(i.onComplete) == 'function') {
            eval('var el = ' + d.body.innerHTML + ';');
            i.onComplete( el );
            element = document.getElementById(id).parentNode;
            element.parentNode.removeChild(element);

        }
    }
13
  • Make sure You have set property permissions for your project. Eg. media and var have writing permisions Feb 2, 2017 at 9:42
  • @KonradSiamro Thanks for informing, we will correct it..... Feb 2, 2017 at 9:44
  • Np, If that helps ill make it as answer for other users ;) Feb 2, 2017 at 10:10
  • @KonradSiamro no , sorry thats not the reason..... Feb 2, 2017 at 10:11
  • can you check system logs? apache / nginx? Feb 2, 2017 at 11:33

1 Answer 1

0

adding below code to JS solved the issue....

if (d.location.href == "about:blank") {
            $(d).remove();
            return;
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.