Jump to content

Browsing a file


Go to solution Solved by KaiSheng,

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

  • Solution

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.