Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:56:19+00:00 2026-05-31T04:56:19+00:00

My site is HTML/Javascript with AJAX calling server-side PHP. I want to allow the

  • 0

My site is HTML/Javascript with AJAX calling server-side PHP. I want to allow the user to click an icon and create a report from MySQL data and then save this on the client’s desktop without doing a page reload.

Options for creating a doc, as I can gather it, appear to be as follows. (I gather it needs to be done server-side, rather than with Javascript.) I’m not sure where the file ends up in each case. Please feel free to correct my misunderstandings 🙂

Method 1 – this appears only to create a .doc file. I’m not sure where the file gets put.

$fp = fopen("method1.doc", 'w+');
$str = "<B>This is the text for the word file created through php programming</B>";
fwrite($fp, $str);
fclose($fp);

Method 2 – this also appears to create a .doc file.

$word = new COM("word.application") or die ("couldnt create an instance of word");
echo "loaded , word version{$word->version}";
$word->visible = 1;
$word->Documents->Add();
$word->Selection->TypeText("Sample text.");
$word->Documents[1]->SaveAs("method2.doc");
$word->Quit();
$word->Release();
$word = null;

Method 3 – also a .doc file, I think.

header('Content-type: application/vnd.ms-word');
header("Content-Disposition: attachment;Filename=method3.doc");

echo "<html>";
echo "<body>";
echo "<b>My first document</b>";
echo "</body>";
echo "</html>";

Method 4 – PHPWord

Method 5 – PHPDocx

I’ve tested 1 & 2 in my home dev environment, but I can’t find the files! What’s the best way forward, please?

Thanks 🙂

BTW, I know there are relevant posts here, here and here, but none really answers the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:56:21+00:00Added an answer on May 31, 2026 at 4:56 am

    Methods 1 & 2 create document on the server side somewhere in filesystem (after that you need to transfer it to the client).

    Method 3 creates document as a response to client request – depending on settings browser will either save it or open in window (or ask ‘Save/Open/Cancel?’).

    I personally would have made java applet or flash application which will have access to your local filesystem. It can load document from server and save to local file system without page reloads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an AJAX deep-linked site. I want PHP to load all the
Okay, so i have the following html added to a site using javascript/greasemonkey. (just
I have a AJAX/Javascript intensive webpage and is trying to create a static version
I've my site pages structure as 1) index.php which calls addline.php using ajax and
Preconditions: No CMS solution, i.e. no Wordpress etc. No Javascript/Ajax, i.e. I want a
I want to use JavaScript to show my XSLT, but on my server nothing
Best reference sites for HTML and JavaScript programming: W3C WebEd Wiki (this site has
I have some code that uses JavaScript templates to create some HTML, including some
i've been tasked with re-organizing a pure HTML site into a CMS. if all
How do I mask the address of another site using HTML? For example, I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.