Hello,
How can we save a page to another drives/devices

I did use a form in my page- result.php-
In result.php I put one button for save As. all of the elements are disabled in this page.

and I hope that the details of that page will be copied to saveas.php,
then, all fields are enabled
and can be saved to any devices/ drives.
Is there any ways to do so?
Currently, only html part (not disabled fields)of that page will be downloaded.

<form name="form1" method="post" action="saveas.php">
<div align="center">
<input type="submit" name="saveas" value="Save As">
<input type="button" onClick="window.print()" value="Print">
</div>
</form>

Recommended Answers

All 8 Replies

i guess it is like maintaining session.
the above code is in edit.php.
by clicking save as, the content of that page will be sent to saveas.php (recognised by the ID) and can be saved to any drives/devices.

Any suggestion?

Member Avatar for diafol

Try this for size:

http://www.boutell.com/newfaq/creating/forcedownload.html

In short, you need to set a php header (content-disposition) and include the filename.

I remember reading something bad about this somewhere. Can't remember much about it. Do your research first before using it in case it has any security flaws.

Try this for size:

In short, you need to set a php header (content-disposition) and include the filename.

Hi,
I put this in my code
<?
header('content-type: application/octet-stream; name=file.html');
header('content-disposition: attachment; filename=file.html');
?

the page is printed when users click a particular result in view.php (which listed all search result) -without display the details.
what I want to do is, when users click a particular result, the details of that page will be displayed. Currently this two things are done, but separately.
I would like to combine both functions in one page /or after being displayed in edit.php, a 'save as' page can be downlable . Currrently, if i try to do so, the downlable page-saveas.php is empty.
any idea on how to copy the id and its detail to another page?

thanks in advance

in short, it is like post a edit.php details to saveas.php.
when users click 'save as' in edit.php page, the details wll be downloaded.
is this possible? in js?

can we use 'submit form' in js?

many thanks

can we use 'submit form' in js?

What sort of question is this? Defenetly yes.
You problem is here, that you may use two different forms, one for display a couple of records from a mysql table,
and a second form to send the user to download that results?

melt the save as button and edit button into one form,
if its a simple search engine, where users can specify terms,
save the entered values into session, or hidden fields.

If the user wants to save the results, you apply a submit button:

<input type="submit" name="download_results" value="Download">

You can submit the form to the same php where you standing.

IF condition is a very simple way to determine which submit button has pressed...

if(isset($_POST["download_results"]))
{
// output the header for file download
// Create here a query based on the posted values
// output the results by echo and the user can download the resport
// if you think the logged in user can get an HTML formatted mail
}
Member Avatar for diafol

I've totally bought the plughole with this one. If I understand you correctly, you want a link to a file, which when clicked will force a browser popup to ask you where to save?

All you need to do - forget forms - no point.

1) Links in files.php all point to one document: download.php
2) download.php knows which file to throw at you via the querystring (via $_GET).


files.php

get a list of all files with their ids from the db:

...
echo "<li><a href="download.php?id={$data['id']}" title="">{$data['filename']}</a></li>";
...

download.php

$file_id = mysql_real_escape_string($_GET['id']);
$sql = mysql_query("SELECT filename FROM files WHERE id ='$file_id'");
...
//get the filename from the db, add any extra path info to it and use content:disposition or whatever else on the "path/to/filename".
...
commented: tq +1

tq ardav and djjozsi,
both of your suggestions are ok.
I intend to do as suggested by ardav but djjozsi suggestion is useful too.
thank you.
it is done now

Member Avatar for diafol

OK - well done. Mark as Solved please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.