samedi 19 mai 2018

request file dynamically add input to the name - Laravel, $request, file

I have these one line of code which is doing its part of storing files in a folder but for some reason throws 500 error.

Code:

//if I put this code then it works fine:
foreach($pix as $key => $p) {

    $request->file('img_2')->storeAs('files/ae/'.$postId, $picRealNames[$key]);
}

But then I have multiple files and I want 'img_2' part dynamic.

foreach($pix as $key => $p) {

    $request->file($p)->storeAs('files/ae/'.$postId, $picRealNames[$key]);
}

Above code leads to 500 error.

I have 1 system and 1 micro-system, both are talking to each other. I have sent multiple files using guzzle post request (from micro-system to another system). And I am trying to loop through those files from a request ans save it to the folder and make an entry to the Database. the code makes an entry to the DB and also saves files to the folder and I can see those images uploaded successfully and I can view them in browser.

but for some reason it would crash.



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

Aucun commentaire:

Enregistrer un commentaire