If you want someone to have the opportunity to help you, please reformat your post as the code is currently unreadable.
Jul 5, 2022
2
Level 1
Attachment from external URL
Hi! I want upload some pictures from an array, and attach images to posts in orchid panel.
foreach ($movies as $m) {
$post = new Post;
$post->title = $m['title'];
$post->description = $m['desc'];
$post->save();
foreach ($m['img'] as $g) {
$post->attachment()->syncWithoutDetaching($g);
}
}
I try
$file = new File(file_get_contents($g);
$attachment = $file->load();
$post->attachment()->syncWithoutDetaching(
$attachment
);
and $post->attachment()->syncWithoutDetaching( file_get_contents($attachment) );
But I got error like "Argument 1 passed to Orchid\Attachment\File::__construct() must be an instance of Illuminate\Http\UploadedFile, string given, called in"
Of coure $g is an url like "http://etc.etc/etc.jpg" is string, but when I use file_get_contents still string but image code ���
But I don't know how to get int from a picture, I want attach for Post model. Thanks if someone can help me
Please or to participate in this conversation.