FileImporter complaining about "Invalid file extension" for .jpg (5.6)

Permalink
I have some fairly straightforward FileImporter code in C5 5.6:

Loader::library("file/importer");
    $fi = new FileImporter();
    $thumb = $fi->import($thumb_path, $XML->name."_imported_thumbnail");
    if (!is_object($thumb))
      echo "Error importing $thumb_path: ".$fi->getErrorMessage($thumb);


$thumb_path points to a JPG file with the extension .jpg.

Still, I always get the error "Invalid file extension". I double-checked the list of file extensions and jpg is definitely on the list.

Anyone have an idea what is going on?

pekka
 
pekka replied on at Permalink Best Answer Reply
pekka
Facepalm - it's the *target* extension it's complaining about, not the source file's.

Adding the file extension to the target file name:

$thumb = 
$fi->import($thumb_path, $XML->name."_imported_thumbnail.".pathinfo($thumb_path, PATHINFO_EXTENSION));
Solves it.

Leaving this up for future generations who may run into the same problem.