php - Permission denied when trying to write file -


i'm getting error:

warning: fopen(name.txt): failed open stream: permission denied in /applications/xampp/xamppfiles/htdocs/phptests/post.php on line 5 not write file

i'm trying retrieve form data , pass text file so:

<?php    $name    = $_post['name'];    $surname = $_post['surname'];     $fh = fopen("name.txt", "w") or die("could not write file");     fwrite($fh, $name, $surname);    fclose($fh);    ?> 

i'm using komodo edit , php files saved in "htdocs" folder provided xampp.

can tell me why i'm not able write file?

as error telling file not writable.

to fix , can update file permission

cd <directory of name.txt> chmod 777 name.txt 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -