Trying to download files via the URL, rename from the .ADM extension to .txt then put contents of each file into a single txt file However its saying the fputs param 2 is a resource The $logfile['name'] is the filename thats stored in the array
Heres my code
foreach($items as $logfile)
 {
  $getfile = $logfile['Download'];
  $newfile = file_put_contents(str_replace('ADM','txt',$logfile['name']), 
 file_get_contents($getfile));
 $name = str_replace('ADM','txt',$logfile['name']);
 $newfile = $name;
 $file = fopen($newfile, 'rb');
 $output = fopen('tmp/test.txt', 'wb');
 fputs($output, $file);
 fclose($output);
 fclose($file);
}
Its downloading each and renaming however its not moving the content & giving me this error
 Warning: fputs() expects parameter 2 to be string, resource given in 
				
                        
The second parameter of
fputsis the content of a file. Not a file resource.Instead of
You‘ll need to get the contents of the file
Or, if you like to use
fopen, you can usefread:Then you can put this content into another file: