I have to migrate some content and everything is fine except the images.
I'm getting the images using file_get_contents() and save the file in the drupal /files folder using the following code:
$image = file_get_contents('http://www.someurl.com/xx/util/yy.jpg'); $file = file_save_data($image, 'yy.jpg',FILE_EXISTS_REPLACE); print $file; // returns the path to the file ( /files/yy.jpg )
So the image is uploaded in the /files folder.
What I'm not able to understand is, how can I add the image to the files table so that I can be able later to use the file object?
I was looking through the files.inc functions for Drupal 6 but I wasn't able to find anything that could help. Should I insert the data manually using db_query()?