I am a “newB” and I am working on image upload in my website. Where I created the form using html I’m using W3Schools . I’m working with their PHP File Upload example right now, and I ran into trouble.Here is the code:
First off, those are not errors, they are notices that mean to alert you to poor coding practices. In this case, simply opening the page will generate those notices, because you haven’t submitted the form yet. Since the form hasn’t been submitted, the $_FILES array is not populated.
The above code worked properly thank you for that.
But now wen I have to store imaage into database its not getting stored with below code.
And wat datatype should I use to stor image to database. Should I use “BLOB” or simple "VARCHAR "
You should be using a BLOB column type. Though myself and many others would argue against storing the image data in a table. Just write the image to a folder and store the path in the table (this route would use varchar for the column type).
Seconded, I usually create an image / uploads table that holds an ID (pk) and a path - you can then write a simple php page that you query with the ID and that returns the full path to the uploaded image (e.g. getimage.php?id=2141 would return yourwebsite.com/path-to-img-with-id-2141).