Upload Multiple files to folder in Magento ,Magento2

Upload Multiple images in Magento, Magento2.



                        /*   $fname get the all images and $upload change array to comma seperated */


                        $fname = $_FILES['upload_file']['name'];
         
                        $upload = implode (", ", $fname);

                                                             


                        if(isset($_POST['submit_image']))    /*  submit_image   name of the submit button */
                        {
                        for($i=0;$i<count($_FILES["upload_file"]["name"]);$i++)          /*  upload_file   name of the file to be uploaded */
                        {

                         $uploadfile=$_FILES["upload_file"]["tmp_name"][$i];

                         $folder=Mage::getBaseDir('media').DS."vendorplace/uploadedfiles/driverfiles".DS;

                         move_uploaded_file($_FILES["upload_file"]["tmp_name"][$i], "$folder".$_FILES["upload_file"]["name"][$i]);
                        }

                        //exit();
                       
                        }



                         $model->setDriverupload($upload);   /* Set the vale in the field in database   */


                         $model->save();

Comments

Popular posts from this blog

Through Postman Api send data through JSON and create simple product in Magento2

Getting product Image in PHTML in Magento2

programmaticlly Create Order in Magento2 with custom options in order