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

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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -