Link to home
Start Free TrialLog in
Avatar of emi_sastra
emi_sastra

asked on

Passing Image API Laravel with MS SQL database

Hi All,

I am a beginner of Laravel and I use MS SQL.
I want to create API to pass image for GET and POST.

The image will be stored to MS SQL database.

How could I do it?

Thank you.
Avatar of David Favor
David Favor
Flag of United States of America image

You might search EE for similar questions.

In general, storing images in a database is a very bad idea, unless maybe you're storing SVG (small) data.

Images are blobs of data with no indexing.

Serving images is better handled by HTTPS than SQL.

If you must use SQL, then you'll either use the largest TEXT field MSSQL supports or more correctly store your images in BLOB data type.

As to how you do it, you'll have a table with 2x columns, one column for a unique id, one column for storing your image.

Then other tables providing indexes for how to lookup the unique image id.

How exactly you do this depends on how you'll be looking up your image.
Avatar of emi_sastra
emi_sastra

ASKER

Hi David,

- You might search EE for similar questions.
I can not find one.

Thank you.
EE's search function tends to... work incorrectly, to me.

I'll try to find some of these. If I can... meaning I saved the links, as I can never find anything in EE search either, I'll add the links.

Summary: All past EE questions cover the same info as I covered above.

Databases are ill suited for storing images.

File systems are far better suited for storing images.
Hi David,

Could you answer my question below, using Laravel
- I want to create API to pass image for GET and POST.

Thank you.
GitHub is your friend...

Search - https://github.com php api - take a look at top 10 results for API implementation templates.

Or search - https://github.com laravel api - for more Laravel-esque code.

Just port this over to Laravel, as Laravel is just another PHP framework.
Hi David,

I still blank about it.

Is this link suitable ? https://github.com/spatie/laravel-medialibrary/issues/1082

Thank you.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.