PHPM-003 Renaming image uploaded with PHPmaker and updating database

This code is for my YouTube The following video

The Code to rename uploaded image using php maker

Enter the following code into the info.php

        // update the file name after upload
		// written by A.B.S for StartPHP.com
		// this text shall not be removed. License is given for use without any liability or warranty.
		// Feb 12, 2017 in Ajax, Ontario, Canada.
        function updateFileName($imgData){
            $oldImageName =$this->$imgData['imageField']->CurrentValue;
            $newImageName =$imgData['prefixField'].$this->$imgData['idField']->CurrentValue.".jpg";//pimg_156.jpg
            $data =array($imgData['imageField']=>$newImageName);
            $this->Update( $data, array($imgData['idField']=>$this->$imgData['idField']->CurrentValue));
            rename($this->$imgData['imageField']->UploadPath."/".$oldImageName, $this->$imgData['imageField']->UploadPath."/".$newImageName);
        }  		
		
In this function in PHPMaker Row_Inserted (whthin the table) you want to update the iamge, insert the code below and customize it.
    function Row_Inserted($rsold, &$rsnew) {
            
    }    
inset the following code:

     $imgArray =array(
            "imageField"=>"YOUR_IMAGE_FIELD",// the field holding image name
            "idField"=>"ID_FIELD",// the ID field
            "prefixField"=>"PREFIX"// put your prefix like image_, product or leave it empty if you don't want prefix
                    );
        $this->updateFileName($imgArray);
which your code becomes like this:

    function Row_Inserted($rsold, &$rsnew) {
        $imgArray =array(
               "imageField"=>"YOUR_IMAGE_FIELD",// the field holding image name
               "idField"=>"ID_FIELD",// the ID field
               "prefixField"=>"PREFIX"// put your prefix like image_, product or leave it empty if you don't want prefix
                       );
           $this->updateFileName($imgArray);            
    }