mercredi 9 novembre 2022

how to show multiple filenames in one json format?

I'm not sure where and how I should use the for loop.

I am using Laravel v5.5. I am trying to upload multiple files on my project. I think if I can add all filenames in one json array I can show them in blade page. How can i do that?


        if(request()->hasFile('urun_resmi')) {
            $files = request()->file('urun_resmi');
            $filename = [];
            foreach ($files as $file) {
                if($file->extension() == 'pdf')
                {
                    $filename = $file->extension() . "-" . $entry->id . "-" . time() . "." . $file->extension();
                }else
                {
                    $filename = $entry->id . "-" . time() . "." . $file->extension();
                }
                $file->storeAs('urunler', $filename, 'public');
                $entry->detay()->update(['urun_resmi' => $filename]);
                
          
                if ($file->isValid()) {
                    $file->move('uploads/urunler', $filename);
                    UrunDetay::updateOrCreate(
                        ['urun_id' => $entry->id],
                        ['urun_resmi' => $filename]
                    );
                }
            }

        }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/onT7iOM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire