I have a weird problem where PHP's file_put_contents()
and fwrite()
(after opening file handle with fopen('filename', 'w');
) functions are not truncating the target file as stated by the PHP docs for fwrite()
. The file resides on a Seagate BlackArmor NAS device, which is mounted on a Linux server (Ubuntu 10.04) using CIFS, as follows:
mount -t cifs -o defaults,credentials=/etc/smbpass/demo.smbpass,uid=1005,gid=1005,dir_mode=0770,file_mod=0660 //xxx.xxx.xxx.xxx/demo/files /var/www/mysite/src/files/
Example:
Contents of myfile.txt: thisisabigfatpandaonwheelsgoingdownthestreet
Run PHP script with code: file_put_contents('myfile.txt', 'blah');
Contents of myfile.txt: blahisabigfatpandaonwheelsgoingdownthestreet
The expected contents of the file is obviously blah
, but that's not the case.
Any ideas?