protected function getFileInformation($path) {
    $file = pathinfo($path);

    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mimetype = finfo_file($finfo, $path);
    // Check if mimetype is supported.
    if (!in_array($mimetype, $this->valid_mimes)) {
      if ($mimetype == 'text/plain') {
        $mimetype = 'application/octet-stream';
      }
      else {
        $this->triggerError('Unsupported mime type: ' . $mimetype);
      }
    }

    $contents = file_get_contents($path);

    return [
      'name'      => str_replace(' ', '-', $file['filename']),
      'filename'  => $file['basename'],
      'extension' => $file['extension'],
      'mimetype'  => $mimetype,
      'contents'  => $contents,
      'size'      => strlen($contents)
    ];
  }
protected function getFileInformation($path) {
    $file = pathinfo($path);

    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mimetype = finfo_file($finfo, $path);
    // Check if mimetype is supported.
    if (!in_array($mimetype, $this->valid_mimes)) {
      if ($mimetype == 'text/plain') {
        $mimetype = 'application/octet-stream';
      }
      else {
        $this->triggerError('Unsupported mime type: ' . $mimetype);
      }
    }

    $contents = file_get_contents($path);

    return [
      'name'      => str_replace(' ', '-', $file['filename']),
      'filename'  => $file['basename'],
      'extension' => $file['extension'],
      'mimetype'  => $mimetype,
      'contents'  => $contents,
      'size'      => strlen($contents)
    ];
  }
protected function getFileInformation ( $ path ) { $ file = pathinfo ( $ path ) ; $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mimetype = finfo_file ( $ finfo , $ path ) ; // Check if mimetype is supported. if ( ! in_array ( $ mimetype , $ this -> valid_mimes ) ) { if ( $ mimetype == 'text/plain' ) { $ mimetype = 'application/octet-stream' ; } else { $ this -> triggerError ( 'Unsupported mime type: ' . $ mimetype ) ; } } $ contents = file_get_contents ( $ path ) ; return [ 'name' => str_replace ( ' ' , '-' , $ file [ 'filename' ] ) , 'filename' => $ file [ 'basename' ] , 'extension' => $ file [ 'extension' ] , 'mimetype' => $ mimetype , 'contents' => $ contents , 'size' => strlen ( $ contents ) ] ; }
Get file information and its contents to upload.

@param (string) $path Path to a file included in the POST request.

@return (array) Associative array. The array contains information about a file.
Get file information and its contents to upload .