Jump to content

Browsing a file


Roopavathy

Recommended Posts

Hello there,

 

I want to use the file type field to browse a pdf or word document in my registration form.I dont know how to use it. Please help me.

 

I have followed the following example.But dont know how to upload a pdf or word document.

 

http://www.w3schools.com/php/php_file_upload.asp

 

Link to comment
https://forums.phpfreaks.com/topic/285436-browsing-a-file/
Share on other sites

First you need to create a form in php.

Second, you need to pass the values you gotten from the form into your database.

I'll show you an example.

This is  your form.

<form method="post" action="xxx.php" enctype="multipart/form-data"> 
<tr>
                            <td><label for="file">File name:*</label></td>
                            <td>
                            <input type="file" name="file" required>
                        </td>
                            
                        </tr>

---

This will be the second page where the value is passed.

move_uploaded_file($_FILES["file"]["tmp_name"],
    "doc/" . $_FILES["file"]["name"]);

the above code, "doc" represents the name of the folder.

the "file" represent the value from the form, in which the file that you are uploading.

the "tmp_name" represents the temporary file name stored in the server.

the "name" is the attributes of the file you uploaded.

 

This is the simplest. 
I did not include any database connection, presume you already know how to, and youtube have lots of tutorials for this.

You can take a look at this.

Link to comment
https://forums.phpfreaks.com/topic/285436-browsing-a-file/#findComment-1465542
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.