How to Upload Files Using PHP Guide



PHP is one of useful script languages to access database. To use PHP, you need to install server then ready to create end-user interface. One of interesting application is the form with uploading file. You will find such kind of form in website nowadays. Before taking further step, first thing is to configure the "php.ini" file. What is php.ini? You may wonder about this file and how to find or create it. Basically, php.ini is configuration file that identifies PHP to server. With this file, server and database recognize PHP as script.

Create HTML Form with Uploading File Section

1.      HTML form
Firstly, you need to create the HTML form. There are many variations of uploading form depends on what kind of file, user, or purpose that want to be obtained. PHP works in server side, but the form will be pathway to connect end-user with server. The form should have several things such button, warning sign, loading file, etc.

2.      PHP script
Form is ready and the next step is to create the Upload File PHP Script. When user clicks the button, the form will display file management in device. This process uses PHP to load properly. Loading file manager only appears from end user, but developer needs to create specific PHP file that's responsible to upload the action. It is called upload.php that contains script to access file, determine file size, check the file, and give sign for failed or success action. The functions of upload file will be explored in the next section.

3.      Checking file
PHP lets end-user to upload any file as long as they meet requirement. However, developer needs script to check whether the file is already uploaded or not. When file is ready, the message will appear to inform and vice versa. Check if file already exists then website is able to process it.

4.      File size
The thing to do is to determine maximum of file. For example, you need to write 500000 when maximum file size is 500 kb. When users try to upload more than this number, error message will be appeared. Sometimes, warning can be seen via progressing bar that stops immediately. File size is important for administrator. To make sure you create limit file size in good ways, it is better to use integer number. Each of websites have their own limitation, but developer should create friendly system to make users understand easily.

5.      File type
Another important thing is file type. Teacher may create website to collect exam from student. Moreover, the file should be in document. Video provider allows users to upload file in mp4 only. Both are the example of importance of file type. To limit file type, you need to specify in upload.php. Experts recommend making form with common file type. For example, picture or photo should be gif, jpg, or png. Document will have file type such as doc, rtf, or pdf.

6.      Last task
To complete Upload File PHP Script, you need to check whether this file works properly or not. Start from uploading form, file size, file type, and then check availability of file in server. After everything is done, upload file is ready to integrate into website or HTML script.





SHARE

About andy

I made this blog just to make about the science that I learned during the study, if there is something wrong please comment below, and do not forget to share, thank you.

    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar