create a txt file with ajax and php
Hey everyone,
i want to write a Script which creates a txt file with some user entered variables.
The communication between the script and my HTML Document with ajax works fine.
But i have some problems with the creation of the file.
Maybe someone find a small mistake in my script...
- <?php
-
- <!-- SAVE POSTDATA PART-->
-
- $content = "test without variables";
- $savename = "test.txt";
- $file = fopen($savename, "w");
- fwrite($file, $content);
- fclose($file);
- echo $savename;
-
- ?>
And the JavaScript Part:
- $("#mybutton").click(function(){
- $.post("generate-txt.php",
- {postname:name,postplc2:plc},
- function(data){
- top.location.href = data;
- });
- });
I always just get a 404 Error, because the Script can't create the file.
Thank you in advance!