0

I made a site, and I wand to upload files through a php form, but when I try to do so, I have the following error:405 Not Allowed nginx. Can anyone help me?

I have checked my php.ini file, and file_uploads were on by default

<!DOCTYPE html>
<html>
<head>
  <title>Untitled</title>
</head>
<body>
  <form method="post">
    Enter Your Text Here:<br>
    <input type="text" name="textdata"><br>
    <input type="submit" name="submit">
    
  </form>
</body>
</html>

<?php
              
if(isset($_POST['textdata']))
{
$data=$_POST['textdata'];

$fp = fopen('data.txt', 'a');

fwrite($fp, $data);
fclose($fp);
}
?>
Jack
  • 11
  • Check the read/write access on the "data.txt" file, and ensure its in the same folder as that script. – Qirel Sep 17 '19 at 10:18
  • 1
    What is the suffix of the file you placed this in? nginx doesn’t allow POST requests to “static” resources, such as files ending in `.htm(l)`, by default. (You did not specify a form action, so this gets submitted to the same URL the page was originally loaded from.) In that case, you’d either need to rename the script to end with `.php`, or configure nginx to explicitly allow POST requests to static resources as well. https://stackoverflow.com/a/44613878/10955263 – 04FS Sep 17 '19 at 10:24

0 Answers0