src/whatsprot.class.php
protected function sendCheckAndSendMedia($filepath, $maxSize, $to, $type, $allowedExtensions, $storeURLmedia, $caption = '')
    {
        if ($this->getMediaFile($filepath, $maxSize) == true) {
            if (in_array(strtolower($this->mediaFileInfo['fileextension']), $allowedExtensions)) {
                $b64hash = base64_encode(hash_file('sha256', $this->mediaFileInfo['filepath'], true));
                //request upload and get Message ID
                $id = $this->sendRequestFileUpload($b64hash, $type, $this->mediaFileInfo['filesize'], $this->mediaFileInfo['filepath'], $to, $caption);
                $this->processTempMediaFile($storeURLmedia);
                // Return message ID. Make pull request for this.
                return $id;
            } else {
                //Not allowed file type.
                $this->processTempMediaFile($storeURLmedia);

                return;
            }
        } else {
            //Didn't get media file details.
            return;
        }
    }
protected function sendCheckAndSendMedia($filepath, $maxSize, $to, $type, $allowedExtensions, $storeURLmedia, $caption = '')
    {
        if ($this->getMediaFile($filepath, $maxSize) == true) {
            if (in_array(strtolower($this->mediaFileInfo['fileextension']), $allowedExtensions)) {
                $b64hash = base64_encode(hash_file('sha256', $this->mediaFileInfo['filepath'], true));
                //request upload and get Message ID
                $id = $this->sendRequestFileUpload($b64hash, $type, $this->mediaFileInfo['filesize'], $this->mediaFileInfo['filepath'], $to, $caption);
                $this->processTempMediaFile($storeURLmedia);
                // Return message ID. Make pull request for this.
                return $id;
            } else {
                //Not allowed file type.
                $this->processTempMediaFile($storeURLmedia);

                return;
            }
        } else {
            //Didn't get media file details.
            return;
        }
    }
protected function sendCheckAndSendMedia ( $ filepath , $ maxSize , $ to , $ type , $ allowedExtensions , $ storeURLmedia , $ caption = '' ) { if ( $ this -> getMediaFile ( $ filepath , $ maxSize ) == true ) { if ( in_array ( strtolower ( $ this -> mediaFileInfo [ 'fileextension' ] ) , $ allowedExtensions ) ) { $ b64hash = base64_encode ( hash_file ( 'sha256' , $ this -> mediaFileInfo [ 'filepath' ] , true ) ) ; //request upload and get Message ID $ id = $ this -> sendRequestFileUpload ( $ b64hash , $ type , $ this -> mediaFileInfo [ 'filesize' ] , $ this -> mediaFileInfo [ 'filepath' ] , $ to , $ caption ) ; $ this -> processTempMediaFile ( $ storeURLmedia ) ; // Return message ID. Make pull request for this. return $ id ; } else { //Not allowed file type. $ this -> processTempMediaFile ( $ storeURLmedia ) ; return ; } } else { //Didn't get media file details. return ; } }
Checks that the media file to send is of allowable filetype and within size limits.

@param string $filepath          The URL/URI to the media file
@param int    $maxSize           Maximum filesize allowed for media type
@param string $to                Recipient ID/number
@param string $type              media filetype. 'audio', 'video', 'image'
@param array  $allowedExtensions An array of allowable file types for the media file
@param bool   $storeURLmedia     Keep a copy of the media file
@param string $caption           *

@return string|null Message ID if successfully, null if not.
Checks that the media file to send is of allowable filetype and within size limits .