Via an XML import I'm getting also an url link to jpg images on an external server. I want to copy the images. I'm tried to do this via UploadedFile() function in Symfony to then add them in my entity.
Via the following code I want to add the url image in the Symfony image object.
$f = new UploadedFile();
$f->openFile($imageUrl);
So after opening the file I want to add them in my image entity.
$image = new image();
$image->setFile($f);
This entity contains the following file parameters:
/**
* Sets file.
*
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
*/
public function setFile(UploadedFile $file = NULL) {
$this->file = $file;
}
/**
* Get file.
*
* @return UploadedFile
*/
public function getFile() {
return $this->file;
}
Then I get the error that arguments are missing. But with an from it works with the following code:
$image = new image();
$image->setFile($request->files->get('images'));