0

How upload files to a server

I want to make a website that you van upload files like word, PowerPoint, etc... With php, How can I do it? And How can I put the uploaded file to a database (with SQL)? and with JavaScript I can do it too?

27th May 2017, 10:38 PM
Rafael
2 Answers
+ 4
Well, doing that requires a lot of steps. I can not say all the details here but here is a guide: 1. Make and HTML file with a form where the user can post the file. Something like this: <form action='php_script.php' method='POST' enctype="multipart/form-data"> <input type="file" name='the_file'> </form> Note: you have to use the method "POST" and the enctype "multipart/form-data". 2. Make the "php_script.php" file that will receive te file and put it in the database. About that here is a link with an example: https://www.w3schools.com/php/php_file_upload.asp 3. Build the database with a column that will receive the file. Here you have two options: A. put the actual file in the database. In this case you had to create the column to receive type BLOB (binary large object). B. store the file in a directory in the server and save the path to it in the database. In this case the type of the column would be varchar. http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx Hope this helps.
27th May 2017, 11:10 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 3
it's not easy for a newbie to make a website that can do all those things you stated, but a simple static website is easy for an average coder to make
27th May 2017, 11:54 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar