I tried this:
$temp = tmpfile();
file_put_contents($temp,file_get_contents("$path/$filename"));
But I get this error: "Warning: file_put_contents() expects parameter 1 to be string,"
If I try:
echo file_get_contents("$path/$filename");
It return to screen the file content as a long string. Where am I wrong?
tmpfile()
creates a temporary file with a unique name in read-write (w+) mode and returns a file handle to use with fwrite for example.
$temp = tmpfile();
fwrite($temp, file_get_contents("$path/$filename"));
The file is automatically removed when closed (for example, by calling fclose(), or when there are no remaining references to the file handle returned by tmpfile()), or when the script ends. look at php ref.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With