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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.