html file
<form ENCTYPE="multipart/form-data" ACTION="./upload.php" METHOD="POST">
<table border=0>
<tr>
<td><INPUT NAME=userfile TYPE=file></td>
</tr>
<tr><td> </td></tr>
<tr>
<td><input type=submit value=Submit>
<input type=reset value=Reset></td>
</tr>
</form>
php file
<?php
$fsize=filesize($userfile);
if ($fsize>10485760){
echo "file size exceed 10MB!";
exit;
}
//copy the file to folder ¡°upload¡±
if (copy($userfile, "./upload/$userfile_name")){
echo "<b>File $userfile_name ($fsize bytes) is sucessfully copied!</b>";
}
else{
echo "<b>Error in copying file</b>";
}
//remove the copied file
unlink($userfile);
?>
more ::
if file size more than 100k, stop user from uploading
change the following in php.ini file
upload_max_filesize
post_max_size
max_execution_time
max_input_time
memory_limit
the max execution time will need to be changed since the script will keep 'executing' till the file is uploaded. The max input time should be changed since it may take a while to transfer data to script. Max post size is the size of data file with other form information and should be larger than your upload_max_filesize