Jump to content

PHP Script - Save as button


qiqinuinaifen128

Recommended Posts

Dear Pro,

 

 

I'm a beginner of php. I am using below php code to save what is inside the testarea, but when i press the button of 'save thank you page' , it's only prompt a window for me to "save" not "save as". How can i change my php code in order to let the user choose their save path/local directory?

I'm testing my code at this website,

http://www.internetbusinessintensive.com/web-creation/webtemplate1/webtemplate1-thank-you-page.html

 

<?PHP
// Check for user data.
if ( $_POST['FileContent'] ) {
// Create a unique-ish filename.
$FileName = "FormToEmail.php";
// Create and open the file.
$FileHandle = fopen ( $FileName, 'w' );
// Write the data.
fwrite ( $FileHandle, $_POST['FileContent'] );
// Close the file.
fclose ( $FileHandle );

// Set file header information.
header ( 'Content-Type: text/html' );
header ( 'Content-Description: File Transfer' );
header ( 'Content-Disposition: attachment; filename="' . basename($FileName) . '"' );
header ( 'Content-Length: ' . filesize($FileName) );

// Push file to client.
readfile($FileName);

// Delete file.
unlink($FileName);

exit();
}
?>

I would appreciate if anyone can point out for me.

Link to comment
https://forums.phpfreaks.com/topic/146667-php-script-save-as-button/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.