Helping ordinary people create extraordinary websites!

How To Upload Files Using PHP

By Ben Sinclair
2005-04-11

The Upload Part


<?php
// ==============
// Configuration
// ==============
$uploaddir = "uploads";
// Where you want the files to upload to
//Important: Make sure this folders permissions (CHMOD) is 0777!

// ==============
// Upload Part
// ==============
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
}
print "Your file has been uploaded successfully! Yay!";
?>
That's it! If you are getting errors or the file just won't upload, make sure that the folders permissions is 0777 where you are uploading the files to. Also check that the folder exists!



Tutorial pages:
 3 Votes

You might also want to check these out:


Leave a Comment on "How To Upload Files Using PHP"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS