Jump to content

Writing to files under windows


tonit

Recommended Posts

I'm trying this simple script on my windows server 2008 standard edition but keep getting errors.

<?php
error_reporting(-1); ini_set( 'display_errors' , 1 );
$file=fopen("2.txt","a") ;
fwrite($file,"Hai");
?>

 

Warning: fopen(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead in C:\inetpub\wwwroot\10.php on line 3 Warning: fopen(2.txt): failed to open stream: Permission denied in C:\inetpub\wwwroot\10.php on line 3 Warning: fwrite(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead in C:\inetpub\wwwroot\10.php on line 4 Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\10.php on line 4 

 

Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/235224-writing-to-files-under-windows/
Share on other sites

IIS is preventing PHP from writing files to C:\inetpub\wwwroot\. I think you need to configure IIS to allow PHP to write files to www directory.

 

To fix this error

It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead in C:\inetpub\wwwroot\10.php on line 3

Set date.timezone to Europe/Paris or whatever your timezone is within the php.ini

date.timezone = Europe/Paris

IIS may need to be restated in order for the changes to take affect.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.