3

I have form for image upload. After uploading the image with title i store the image in a directory. Instead storing the image name & title into database table i want to store that information into a .json file as same as a record goes to a table of database.

1 Answer 1

20

You can take the benefit of File Storage functions in Laravel

use

use Illuminate\Support\Facades\Storage;

and then

 $data = [
    "name" => $image_name,
    "title" => $image_title
]

    Storage::disk('public')->put('images.json', json_encode($data));

and this file will be save in public folder

References:

Laravel -> File System

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.