Situation: Users upload documents through web form and the documents are stored in MySQL (InnoDB) as MEDIUMBLOB.The rationality of this versus to store the original document on the webserver is the web form is only accessible to a small scale of users and the website admin does not want to have these documents stored on the webserver especially without confirming the content of these documents.Condition: Currently limited to MySQL, HTML, JavaScript and PHPGoal: Users click on a hyperlink/button which calls a function that will convert MySQL BLOB data type to the original document to make accessible for download or through the webpage for administration or users.If there are better methods of storing these documents in the database or without storing on the webserver, I am open to new suggestions that would make this goal easier.
Can files such as PDF and JPEG be stored in MySQL BLOBs to keep them off the webserver?
mysql;download;files
Situation: Users upload documents through web form and the documents are stored in MySQL (InnoDB) as MEDIUMBLOB.... the website admin does not want to have these documents stored on the webserver especially without confirming the content of these documents.Unless you have an unusual setup, a server would have the database system as well as the webserver software on the same computer, so chances are regardless how the incoming file data is processed, it will be stored on the server in general.Goal: Users click on a hyperlink/button which calls a function that will convert MySQL BLOB data type to the original document to make accessible for download or through the webpage for administration or users.The problem with your approach is that the database engine must run and handle your data, and your system needs to have enough memory or swap space to handle a large set of data. On top of that, that data needs to be identified in the database via a key of some sorts. What's worse is that the table can become extensively large if a lot of files are uploaded. Before trying this method, I'd recommend setting up a personal web server on your local computer with mysql installed and create a table with 1,000,000 or more records with a bunch of text per record, then try managing that table. You'll notice some functions take time such as sorting all the entries in the table.There's a couple answersIf you're still OK with storing stuff on the server but the only real concern is to make certain content not accessible to the public then make a basic upload form, but make it so that after the upload is complete, the file is moved to any other accessible location on the computer outside of document root. (and outside of ftp root). That way, your server script as well as the user with root access to shell will be the only things that can access the uploaded files.If you still want to keep files away from the server, then I'm afraid you'll need to rent another server as well. One server can be just for files only while the other can be just for public-facing web pages. If you use this method, then you'll need to use some kind of program or protocol that allows your script running the web pages to communicate with the file server to manipulate the files. An FTP server on the file server and the script accessing that FTP from the web page server would work, but you might want a more secure option, but that's another topic in itself.