I have a short PHP program which reads a file from a remote web site. If I choose "Save As" for this file, I want the default filename and extension to differ from the original. In other words, if the remote filename is abc.txt, I want the default "Save As" to be def.csv. I thought that the move_uploaded_file function would do the trick, but it does not. Here is my code:
<?php
$url = "http://ieeexplore.ieee.org/otherfiles/OriginalFilename.txt";
$file=@fopen($url,"r");
$ofile="MyNewFilename" . ".csv";
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($url));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
ob_clean();
flush();
move_uploaded_file($_FILES[$url]['tmp_name'],$ofile);
$a=file_get_contents($url);
print "$a\n";
exit;
?>
Thanks for any suggestions you might have.
Sanford Stein
CyberTools Inc.