Helping ordinary people create extraordinary websites!
$1 CPM Advertising For A Limited Time Only
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

How to Upload Files with PHP

By Darren W. Hedlund
2005-06-21


How to Upload Files with PHP

This tutorial will cover how to make a basic PHP upload script. You can easily convert or change it.

You need a PHP enabled host, the ability to upload, and HTML or PHP knowledge to change the script around to fit your needs

This is the basic code:


<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2048000">
File: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload" />
</form>

<?php
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES["userfile"]["tmp_name"], "$/images/" . $_FILES["userfile"]["name"]);
echo "<p>File uploaded successfully.</p>";
}
?>


You can change the "/images/" to any directory you want.

You may also want to password protect the file. This is so only webmasters or selected people can view it.



Tutorial Pages:
» How to Upload Files with PHP


 | Bookmark
Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1

Ask A Question
characters left.