<?php
echo "<center>";
@$action = $_POST["action"];
$max_size = "1048576";
echo "
<form action='upload.php' method=post enctype='multipart/form-data'>
(max size: $max_size bytes/".($max_size/1024)." kb):<br>
<!-- This is NOT a secure method of checking filesize, but it tells the user if he tried to upload a file too big before
he waits for the huge file to upload, make sure to check the filesize after the form is sent as well -->
<!-- <input type='hidden' name='MAX_FILE_SIZE' value='$max_size'> (removed because it wasn't working properly) -->
<input type='file' name='filename'><br>
<input type='hidden' name='action' value='upload'>
<input type='submit' value='اپلود کن'>
</form>";
if ($action == 'upload')
{
if ($_FILES["filename"]["size"] > $max_size) die ("<b>فايل بسيار بزرگ است! Try again...</b>");
copy($_FILES["filename"]["tmp_name"],"upload/".$_FILES["filename"]["name"]) or die("<b>Unknown error!</b>");
echo "<b>فايل با موفقيت اپلود شد</b>"; // for debug --> $filename --> ".$destination."/".$filename_name."</h2>";
}
?>