irsyadadl's avatar

Upload multiple files.

I'm trying to upload multiple files, is there any efficient way other then below. Because, when I do this, I got problem when the network is so slow. Because all the image not executed successfully.

$thumbnails = request()->file('thumbnail');
foreach ($thumbnails as $thumbnail) {
    $thumbnail_name = $thumbnail->store('posts');
    $post->postImages()->create([
        'path' => $thumbnail_name,
    ]);
}

Thanks in advanced.

0 likes
2 replies
laracoft's avatar

@irsyadadl

The way you listed is a pretty minimal (read: efficient) method already. Your problem is not one of efficiency, but rather, one of robustness, i.e. poor network issues.

You could use a Progressive Web App (PWA) to store the images on client side and wait until the network recovers before transmitting, but that is another tech stack by itself.

Please or to participate in this conversation.