WC_Product_CSV_Importer_Controller::validate_file_path
Runs before controller actions to check that the file used during the import is valid.
Method of the class: WC_Product_CSV_Importer_Controller{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Product_CSV_Importer_Controller::validate_file_path( $path ): void;
- $path(string) (required)
- Path to test.
Changelog
| Since 9.3.0 | Introduced. |
WC_Product_CSV_Importer_Controller::validate_file_path() WC Product CSV Importer Controller::validate file path code WC 10.3.3
protected static function validate_file_path( string $path ): void {
try {
FilesystemUtil::validate_upload_file_path( $path );
} catch ( \Exception $e ) {
throw new \Exception( esc_html__( 'File path provided for import is invalid.', 'woocommerce' ) );
}
if ( ! self::is_file_valid_csv( $path ) ) {
throw new \Exception( esc_html__( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
}
}