+ 1

How to send pics from front end to backend(DB)

Hey, Anyone help me out how to send pics from front end File tag to backend DB, most specifically in Node Js backend and Ejs or any html front end.

26th Oct 2020, 10:37 AM
Priyajit Nayak
Priyajit Nayak - avatar
3 odpowiedzi
+ 1
When you say "file tag", I think you mean input type="file". Did you look at this? https://projectsplaza.com/upload-image-nodejs-express/ What kind of database is it? SQL or MongoDb? Regardless, the best approach at some level sends the image file data like most file uploads. If you use SQL, blob or a similar data type is great for storing binary file data.
27th Oct 2020, 9:01 PM
Josh Greig
Josh Greig - avatar
0
Yeah, Josh, File tag means type= file, but you are saying to converting the image to binary and store it in DB, Is there any other ways like using firebase or any thirdparty apps to store the file??
28th Oct 2020, 4:26 AM
Priyajit Nayak
Priyajit Nayak - avatar
0
Priyajit wrote, "Yeah, Josh, File tag means type= file, but you are saying to converting the image to binary and store it in DB, Is there any other ways like using firebase or any thirdparty apps to store the file??" Response: jpg, png are all binary file formats and binary is the most efficient format. Storing in binary doesn't mean converting to strings of 1's and 0's if that's what you're thinking. "Binary" as in not string or human-readable text... not a varchar. You could store in base-64 to use only 6 of the 8 bits per byte but that's less efficient use of your database capacity, bandwidth, and requires more processing time to encode and decode base 64 in your API's. Base 64 can be used for storing binary data in JSON format but it'll hurt performance. I see from the following discussion that you can store images in firebase but I haven't done it myself yet. https://stackoverflow.com/questions/13955813/firebase-storage-how-to-store-and-retrieve-images
28th Oct 2020, 8:18 AM
Josh Greig
Josh Greig - avatar