class action { function save_file() { # first, save the file with a temporary filename $save_path = dirname(__FILE__) . basename( $_FILES['userfile']['name']); if(move_uploaded_file($_FILES['userfile']['tmp_name'], $save_path)) { $ret = "The file ". basename( $_FILES['userfile']['name']). " has been uploaded"; } else { $ret = "Sorry, there was a problem uploading your file."; } return $ret; }}$myform = '<form enctype="multipart/form-data" action="sample.php" method="POST"><!-- MAX_FILE_SIZE must precede the file input field --><input type="hidden" name="MAX_FILE_SIZE" value="30000" /><!-- Name of input element determines name in $_FILES array -->Send this file: <input name="userfile" type="file" /><input type="submit" value="Send File" /></form>';if ($_FILES) { $a = new action(); $result = "<i>".var_dump($_FILES)."</i><br />\n"; $result = $a->save_file() . "<br />\n";}/* when I upload a file, I get these errors:Warning: move_uploaded_file(/var/www/somefile.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /var/www/play/sample.php on line 37Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpADa3ik' to '/var/www/somefile.txt' in /var/www/play/sample.php on line 37*/