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 = '
Send this file:
'; if ($_FILES) { $a = new action(); $result = "".var_dump($_FILES)."
\n"; $result = $a->save_file() . "
\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 37 Warning: 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 */