phpsane Posted November 22, 2018 Share Posted November 22, 2018 Php Buddies, Just how do you insert an uploaded img via html for ($_POST) to mysql tbl and what type of column should it be ? Also, how to link the img from the mysql column to a webpage ? Following html links the img from a folder/directory to a webpage: <a href="../html-link.htm"><img src="flower.jpg" style="width:82px; height:86px" title="White flower" alt="Flower"></a> Quote Link to comment Share on other sites More sharing options...
requinix Posted November 24, 2018 Share Posted November 24, 2018 Either you store the uploaded file as a file on your server and your database has information about it (like path and file type), or you store the data directly in the database. The former is much more common. How you link to it depends on which option you choose and whether you want the files to be publicly-accessible by anyone. Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 25, 2018 Share Posted November 25, 2018 Here's a tutorial about storing a blob using mysqli that covers some very important aspects of this problem, in particular the mysql 'max_allowed_packet' setting. There is a substantial cost to storing blobs in a relational database which is why it is often avoided. Conversely there is simplicity and security in knowing that your database is complete, and backing up your system doesn't involve separate maintenance of the filesystem separately. With blobs in a db, you pay an extra price for retrieval: PHP retrieves BLOB from DB into PHP Memory -> PHP Returns to HTTPD -> Client With filesystem storage, which often has a native OS buffer, it can return the files directly to the client if the files exist in webspace. HTTPD -> Client PHP doesn't have to be involved at all, unless you have a scheme that keeps the images off the webroot due to some security requirement, and even if you don't, you can use readfile to dump the file directly to the output buffer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.