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 - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

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