2

I have the following code:

header('Content-type: text/plain');
header("Content-Disposition: attachment; filename=bookmark.adr");
readfile('bookmark.adr');

This makes a save-as popup where an user can save the bookmark.adr file. But I would like to custom generate the content of that file. How can I generate the content and let that file be popupped as save-as?

Thanks!

1 Answer 1

1

Just don't do readfile(). Echo out whatever you want that file to contain instead.

Your Content-Disposition header is what will tell most browsers to prompt the user to save the file.

Sign up to request clarification or add additional context in comments.

3 Comments

@Jordy, The source code of what page? Your file will contain whatever you echo out. If that's HTML, then that's what will be in the file.
Last question. What should the Content-type be for a .adr file?
@Jordy, I'm not familiar with adr files, but some quick Googling suggests text/directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.