0

I am trying to get a variable from the query string and write it to a text file. I have tried like this:

<?php
$content=( $_GET['var'] );
echo $content;
$file = fopen("etlLOG.txt","w+");
echo fwrite($file,$content);
fclose($file);
?> 

I get the following errors:

Warning: fopen(etlLOG.txt) [function.fopen]: failed to open stream: Permission denied in E:\Users\george\listener.php on line 8

Warning: fwrite(): supplied argument is not a valid stream resource in E:\Users\george\listener.php on line 9

Warning: fclose(): supplied argument is not a valid stream resource in E:\Users\george\listener.php on line 10

jayt.dev
  • 975
  • 6
  • 14
  • 36

5 Answers5

2

You may need to change the permissions as an administrator. Open up terminal on your Mac and then open the directory that etlLOG.txt is located in. Then type:

sudo chmod 777 etlLOG.txt

You may be prompted for a password. Also, it could be the directories that don't allow full access.

OR

PHP

chmod : Attempts to change the mode of the specified file to that given in mode.

chmod

Shakti Patel
  • 3,762
  • 4
  • 22
  • 29
1

Well it appears that the web server does not have access to that file. So used ftp fopen provided the correct credentials and paths and finally i did managed to access and edit the file

jayt.dev
  • 975
  • 6
  • 14
  • 36
0

If you are running WAMP on windows

1) login as an administrator

2) Install wamp

3) Download subinacl.exe from microsoft:

4) grant permissions to the regular user account to manage the WAMP services: (subinacl.exe is in C:\Program Files (x86)\Windows Resource Kits\Tools)

subinacl /SERVICE \MachineName\wampapache /GRANT=domainname.com\username=F subinacl /SERVICE \MachineName\wampmysql /GRANT=domainname.com\username=F

5) logout and log back in as the user. They should now be able to launch the WAMP taskbar application and control the WAMP service.

Subodh Ghulaxe
  • 18,333
  • 14
  • 83
  • 102
0

My guess is that PHP is trying to create the file at 'C:\WINDOWS', so the solution wouldn't be to set permissions there.

I would suggest you use a specific location, example: create a folder at the same location as your php script and use it to create the files:

$filePath =  dirname(_FILE_) . "/temp_vars/etILOG.txt";
$file = fopen($filePath ,"w+");

Kind regards,

KLiFF
  • 382
  • 2
  • 18
0

The code you are running is trying to create the etlLOG.txt in the same folder as your PHP script. You need to give Full Permission to your IUSER_ account on the E:\Users\george folder.

If you do not know how you can browse the following links

http://technet.microsoft.com/en-us/library/bb727008.aspx

http://www.wikihow.com/Change-File-Permissions-on-Windows-7

How to set 777 permission on a particular folder?

Community
  • 1
  • 1
asarfraz
  • 518
  • 3
  • 8