PHP Tutorial : How to make a file uploader

Hi,

In this php tutorial you will learn how to make a file uploader. Less words, and here we are : first we create the html form

<form action="" method="POST" enctype="multipart/form-data">
Browse file to upload <input type="file" name="filetoupload" id="filetoupload"><br/>
<input type="submit" name="sb" id="sb" value="Upload now">
</form>

Now that we have the html form created, I’ve pushed the action on itself. So, no need to create another separate page to process the data.

Here is the php code

<?php

if(isset($_POST['sb'])) {
$path = "yourpath";
$file = $_FILES['filetoupload']['name'];
move_uploaded_file($_FILES['filetoupload']['tmp_name'], "$path/$file");
}
?>

Bulk php file uploader is now done,

Enjoy!

This entry was posted in Usefull PHP and tagged , , . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>