im trying to insert an array values into the file using foreach.. and if the file size became up to 1MB (1000000byte). the script create a new file and put the value inside...
this is the code what i used :
foreach($array as $code){
if(filesize($file_name) < '1000000'){
$update_file = file_get_contents($file_name);
file_put_contents($file_name,$update_file.$code);
}else{
$open = fopen($file_name.rand('99999'),'w');
file_put_contents($file_name,$code);
}
echo filesize($file_name);
}
now the problem is the function "filesize()" is always returning 0,, but if i remove the code above it and put echo filesize($file_name);
only in the page .. it return the right value (size of file), the script also make only 1 file even it became more than 1MB because the filesize is 0 as filesize() function return !.
i checked this question PHP Problem : filesize() return 0 with file containing few data? but it still not working even i follow the answer #1
i wish that you understand my problem.. and im sorry for my english.
$file_name
is in the header of the page, it contains a string value and itsfile.txt
. – Savagery