Saving remote image to assets field in entry
Your best bet to get the image in as an Asset in one go would be to use 

$response = craft()-&gt;assets-&gt;insertFileByLocalPath($fileLocation, $fileName, $targetFolderId, AssetConflictResolution::KeepBoth);



$fileLocation would be the file's location on the disk
$fileName is the desired file name
$targetFolderId is the Assets folder, obviously. Look it up in craft_assetfolders table
The last argument is how to resolve any naming conflicts.


This will return an AssetOperationResponseModel object.

$fileId = $response-&gt;getDataItem('fileId');


This will get you the file Id. For an in-action example, see AssetsController::actionExpressUpload()

Note: This will copy the file to the location. This method is intended for importing a file into an Assets source from a different location, say, a temporary folder. It will probably work alright if the file is already in it's intended place, but I still feel like I need to warn you about this

You can also use this to import images to external sources, by the way.