How To Upload File To Server Using PHP & Save The Path In MySQL

When it comes to uploading file, the best way to do it, would be to upload the file to a file server and save the path of the file in the database. In this case, I have used PHP to upload the file to a directory and save the path of the file in the MySQL database.

Basically, you will need a simple HTML form and a PHP code to upload the file. So, here’s the HTML form.

And here’s the PHP code. Do note I have also added the logic to check whether the file is already there in the destination folder before the upload takes place.

So, that’s it for this tutorial. Stay tuned for more.

Author: Lahaul Seth

A programmer and a web developer, he is the founder of Lion Blogger. His main hobbies are web design & development and providing writing services to clients.

Share This Post On

6 Comments

  1. Do you write all of your blogs urself or do you have a team?

    Contractors? Do you have guest bloggers?

    Post a Reply
  2. Thanks Man Great Code.Great Help

    Post a Reply
  3. Great Content! Love the Work!!!

    Post a Reply
  4. That’s good Code and clear comment. Thankyou for your simple code but give newbie to easy understanding about the subject.

    Post a Reply
  5. I think I’ve worked it out from the code:

    The Database is called: fileupload

    table:filedetails

    Rows:
    filepath
    filename
    description

    Post a Reply
  6. what are the details of the database? e.g. the name of the tables and rows in the database?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This