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!

4 Responses to “PHP Tutorial : How to make a file uploader”

  1. Andrea Says:

    lol you kidding? that way i could upload a php file, that’s not smart ;)


  2. admin Says:

    Sigh, you’r right. As mentioned elsewhere I, err, “inherited” this blog. And really need to spend a weekend reading the posts that don’t belong to me and clean them up.

    Thanks for bringing this one to my attention.


  3. someone Says:

    it says it’s a “file uploader” so yes you can upload .php files too because its a file, so what would be the issue?


  4. andrew Says:

    can you upload mp3 vid with this script.


Leave a Reply

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