Archive for VTW 
 


       VTW Forum Index -> PHP
computergeek67

PHP Uploader

Want to make a simple PHP file uploader for your site?
Here it is!

Code:
<?php

$action = $_POST["action"];
$max_size = "10485760"; // Max size in BYTES (Currently 10MB)

echo "
<html>
<center>
<form action='upload.php' method=post  enctype='multipart/form-data'>
Select A File To Upload:<br>

<input type='file' name='filename'><p>
<input type='reset' value='Reset'>
<input type='hidden' name='action' value='upload'>
<input type='submit' value='Upload File'>
</form>";


if ($action == 'upload')
{
    
    
    if ($_FILES["filename"]["size"] > $max_size) die ("<b>File too big!  Try again...</b>");
    
    
    copy($_FILES["filename"]["tmp_name"],"./".$_FILES["filename"]["name"]) or die("<b><font color='red'>Unknown error! Please e-mail me if the problem persists.</b></font>");
    echo "<b><font color='green'>File Uploaded. <a href='../uploads/' target='_blank'>Click here</a> to see your file(s).</b></font>"; // for debug -->  $filename --> ".$destination."/".$filename_name."</h2>";
    
    
}
    
?>


The variables at the beginning set the Action to post the picture into the supplied folder uploads.
Hence we need to create a folder in the main directory with CHMOD 777 [all permissions] to enable the files to be uploaded.
The form is basic input fields.
Files that are larger than the allocated amount will not be uploaded.

-The Anizone

       VTW Forum Index -> PHP
Page 1 of 1
Create your own free forum | Buy a domain to use with your forum