webCOMAND

importer::import_from_file()

Imports objects from an external file or accessible URL.  The contents of the given URL must be in well-formed cJSON or CSV format.

Prototype

mixed import_from_file(string $url)

Parameters

  • url - A file system path or URL to a cJSON or CSV file to import.

Return

The number of imported objects, or FALSE if an error occurred.  Errors will be logged to the importer event log.

Example

$repo = comand::repo();
$importer = new \io_comand_util\importer($repo);
$result = $importer->import_from_file('/file/path/import.json');
if($result===FALSE) {
    echo($importer->event_log->as_html());
}