Hi,
I must disagree with Stephen, due to the RULE of solid coding. ALLWAYS check user input from the SERVER side. This means that the html to limit certain sizes and types should be implimented, you must plain for the user who wishes to circumvent your code.
So the syntax is close to what the you sould follow albiet if I might add these few tips:
- Move the check_file into a function for easy use and future painless debuging.
- Move all "magic" values like 1000000 into a varible like $max_file_size
- Read this section on file handling skills.
http://php.net/manual/en/ref.filesystem.php
- Check the (".txt" ) a little boost might be..
$file_type =
array_pop(explode(".",$filename));
You could even get savy and compare the result to a array of exceptable values!!
(don't know if you're ready for that)
- last but not least: ALLWAYS make sure that there is not harmful code in an up load and it's NOT a .php .
Well, That should be enough food for thought for now.
Zoom - zoom - zoom,
COPE