Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rumnaz khan's avatar

Laravel API for posting image in Flutter

hi! I was making API for laravel application that stores transaction information of a company. with every transaction there will be an invoice jpg file uploaded. the info will be sent through Flutter application. transactionApiController:

        if ($request->hasFile('image')) {
          $file = $request->file('image');
          $name = uniqid().$file->getClientOriginalName();
          $file->move('public/uploads/', $name);  
          $image = $name;
        }
        $transaction= auth()->user()->transaction()->create([
            'amount'=> $request->amount,
            'fabricator_id'=>$request->fabricator_id,
            'image'=>$image,
        ]);
        
        return 'successfully added transaction';

i checked the API with postman and everything works. But now the app developer wants the image in byteArray. So my question is that is it a standard practice to store image as ByteArray in database as there will be hundreds of transaction per day and hundreds of invoices uploaded. Also is there a problem to save it in a file like we do in web applications.

0 likes
1 reply

Please or to participate in this conversation.