How to Create Upload File

In this article, we are going to learn how to create Upload File. This simple Upload File the users enable to upload any kind of files and save into the database table. Creating one file upload for the files that we are going to upload, one TextBox for the file name, and one TextArea for the file description as shown in the image below. Result Here's the simple source code to create as shown in the image above.
  1. <div class="row-fluid">
  3. <div class="span4">
  4. <!----- form ---->
  5. <form action="upload.php" method="post" enctype="multipart/form-data" name="upload">
  6. <label style="color:blue; font-size:18px; font-family:cursive;"> File </label>
  7. <input name="uploaded_file" type="file" class="input-xlarge" required/>
  8. <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
  9. <label style="color:blue; font-size:18px; font-family:cursive;"> File Name </label>
  10. <input type="text" name="fname" required>
  11. <label style="color:blue; font-size:18px; font-family:cursive;"> Description </label>
  12. <textarea name="desc" cols="" rows="" class="input-xlarge" required></textarea>
  13. <br/>
  14. <input name="Upload" type="submit" value="Upload" class="btn btn-primary btn-large" />
  15. </form>
  16. <!---- end form -->
  17. </div>
  19. <div class="span8">
  21. <table class="table table-bordered">
  22. <tr>
  23. <th>File Name</th>
  24. <th>Description</th>
  25. <th>Date Upload</th>
  26. </tr>
  27. </thead>
  28. <?php $query=mysql_query("select * from up_files")or die(mysql_error());
  29. while($row=mysql_fetch_array($query)){
  30. ?>
  31. <tr>
  32. <td><?php echo $row['fname']; ?></td>
  33. <td><?php echo $row['fdesc']; ?></td>
  34. <td><?php echo date("M d, Y h:i:s A",strtotime($row['fdatein'])); ?></td>
  36. </tr>
  37. <?php } ?>
  38. </tbody>
  39. </table>
  40. </div>
  42. </div>

Let's try this one.

We are going to select a file that we are going to upload, enter the file name, and enter the file description as shown in the image below. Result After that, we are going to click the "Upload" button to save into the database table as you can see in the image below. Result Kindly click the "Download Code" button below for full source code. Thank you very much. Hope that this tutorial will help you a lot. Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment