hey I've recently created a script so that people can upload files onto my domain. however i keep getting "500 internal server error". please help me look at my script and tell me what's wrong.(I have a "files" folder in the same folder as the scripts with permissions 777) Thank you very much.
Index.php
upload.php
Index.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index</title>
</head>
<body>
<?php
$password = "password";
if ($_POST['txtpassword']!= $password) {
echo "Invalid Password./No password entered.";
?>
<form name="form" method="post" action="<?php echo $_SERVER['php_SELF'];?>">
Password:
<input type="password" name="txtpassword" />
<input type="submit" value="Submit" />
</form>
<?php
}
else {
?>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="33554432" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
<?php
}
?>
</body>
</html>
upload.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload</title>
</head>
<body>
<?php
$target_path = "files/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
</body>
</html>
Last edited: