Image Importer

Permalink
Hi,

I am importing data from an xml file and using it to create pages in c5. This is working fine and loops over the xml results to create the pages. I have a url of a file that i would like to upload and assign to a page attribute.

When i pass the url of the file into the file importer, it doesnt work. I cannot find any documentation any where on this and cannot see why this is not working. Does c5 only allow images uploaded from a form with this script...?

Loader::library("file/importer");
$fi = new FileImporter();
$newFile = $fi->import('http://www.externalsite.com/image.jpg');


Any guidance appreciated. Is this the first restriction I have found with c5...

 
shahroq replied on at Permalink Reply
shahroq
As C5 Doc at file importer helper stated:
(http://www.concrete5.org/documentation/developers/files/importers):
Loader::library("file/importer");
$fi = new FileImporter();
$newFile = $fi->import($pathToFile, $nameOfFile, $fileObject);

$pathToFile - the path to the file on the LOCAL web server.
So my suggestion is first write a code to parse xml file, and copy all images to a path at your local (somewhere like files/myexternalfiles/).
Then start importing pages based on copied files.