I am trying to make a notepad application which saves files if you press save, but it gives an error. I think the script(or apache) doesn't have the permissions to write to the disk but I might be wrong.
Does anyone know what to change about my code or how to set the permissions? It would be heavily gracious and appreciated if someone could fix this problem for me.
Code(Yes I know this is spaghetti-code but this is how I learned html and php):
<html>
<style>
button {
display: inline-block;
background-color: #4CAF50;
padding: 15px 32px;
font-size: 16px;
font-size: 16px;
color: white;
text-align: center;
border: none;
}
</style>
<style>
input {
display: inline-block;
background-color: #4CAF50;
padding: 15px 32px;
font-size: 16px;
font-size: 16px;
color: white;
text-align: center;
border: none;
}
</style>
<center><b><font size="7">Notepad</font></b></center>
<br>
<center><form>
<textarea rows="1" cols="50" name="filename">filename</textarea>
<br>
<textarea rows="1" cols="50" name="text">Lorem ipsum</textarea>
<input type="submit" name="submit" value="save">
</form></center>
<br>
</html>
<?php
if(isset($_GET['text'])) {
$text = $_GET['text'];
$filename = $_GET['filename'];
$myfile = fopen("$filename", "w") or die("Unable to open file!");
$txt = $text;
fwrite($myfile, $txt);
fclose($myfile);
echo("<center>Your file is saved as $filename</center>");
}
?>
BTW: I am hosting this script on my LinuxMint(Ubuntu linux) computer using Apache2 and PHP