I am working on an assignment where I need to load information into MySQL including an image to be able to pull using PHP. I have uploaded information into a database with PHP previously, but I have never done an image (previously we were pulling images from an image folder instead of a database). This is for a practice e-commerce site so I need to upload the product name, description, image, and price for each product. He didn’t teach us how to upload images into a database and told us to figure it out. I have watched numerous videos and read a lot of information but I am unsure how to apply it and am very confused at this point. Any help is greatly appreciated.
If you are expected to self-learn fundamental elements of web programing, what is the instructor being paid for?
Storing the actual image data in a database table has a number of issues and should be avoided. The disk file system is designed for the storage of files.
You would upload and store the image in a folder in the file system. You would either insure that the filename is unique and store just the filename in the column in the database table or you would more easily just name the image using the product id.
That has seemed to be the theme this semester, but alas this is the final so I just need to get through it so that I can focus on my own learning of PHP before next semester. It’s been quite deflating to be learning stuff that I won’t use ever and will make me look like I have no idea what I am doing in future job positions.