1

I created the custom option for file upload, If i choose the file and click the upload button i want to upload file, i don't know how to do this customoption

In Magento if choose the file and click the add to cart button file uploaded but I don't want this functionality.so what i need is if I click the upload button after choose the file, i want to upload the file. this is my code.

$jq(document).ready(function(){

    $jq("#click-me").click(function(){
             var imgVal = $jq('.choose').val();
            if(imgVal==''){
            return false;
            }
            else{
                $jq( "#myProgress" ).removeClass( "hide-progress" ).addClass( "add-progress" );


            }
        move();

        });

});
function move() {
  var elem = document.getElementById("myBar");
  var width = 10;
  var id = setInterval(frame, 10);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++;
      elem.style.width = width + '%';
      document.getElementById("label").innerHTML = width * 1  + '%';
     }
     }

}

can you please help..

3

You can use the below code in your controller action to upload the file:

 if (isset($_FILES['file']['name']) and (file_exists($_FILES['file']['tmp_name']))) {
            $uploader = new Varien_File_Uploader('file');
            $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
            $uploader->setAllowRenameFiles(false);
            $uploader->setFilesDispersion(false);
            $path = Mage::getBaseDir('media') . DS;
            $uploader->save($path, $_FILES['file']['name']);
            $filename = $_FILES['file']['name'];
            }
  • I added some code in my question.please help – Jenith Samuel Feb 15 '17 at 4:01
  • I have provided the code to upload file. To implement progress bar you will find lot of reference from google. – Prasanta Hatui Feb 15 '17 at 5:33
  • After I upload the file,I want show that file in cart page and ordered that product,I want to show that file in admin page.I removed the upload file Fuctionality from file.php please help – Jenith Samuel Feb 24 '17 at 12:08
2

well native magento wont provide by the default that feature.

you can intigrate third party libraries for that just like plUpload

so use that kind of library.

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