is there any command of save page as in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

is there any command of save page as in PHP

Post by waseem83 »

Can any body tell me that ,is there any command of PHP which can do similar to the command Save Page As of browser.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: is there any command of save page as in PHP

Post by Darhazer »

PHP is running on the server. It generates HTML or any other output, and browser display the output.
You have to understand the difference between the server side and client side, and where each one occurs.

Since PHP is running at the server side, you cannot perform a Save As, which is a client side functionality.
You can howerver send a Content-disposition:attachment header, so the browser will ask the user to save the file. Do not forget to send the Content-type header as well.
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Re: is there any command of save page as in PHP

Post by waseem83 »

Thank you very much for your reply sir,
I have wrote the code =======>

header('Content-Disposition: attachment; filename="saveHtmlPage.htm"');

From this code i can get the alert window which ask whether to save page or not?.

Is there any possibility that there will be no alert window shown after executing header code.
and i give path of the folder and html file could be saved into that folder?.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: is there any command of save page as in PHP

Post by Darhazer »

No, this will be huge security issue. If a web page can save file without asking the user, then any page can install malware.

The only way you can access user's file system is trough client-side technology as a JavaApplet or ActiveX object, and the user should permit those actions.

And why you are asking about saving files on the user's computer? Maybe you are searching for the wrong pill.
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Re: is there any command of save page as in PHP

Post by waseem83 »

i was asking because i want to save image as designed by client and save that page into our record so we can email that page to admin of that website with full saved html code.

I want to do same as this link do

http://www.vistaprint.co.uk/vp/ns/studi ... 12%3a58+AM

There is another way that we can take print screen of the image designed by user.
Can you tell me how can i take print screen of static html page programatically.Then save that image to our database and also send it to the email of admin.

I hope you understand why i want to save html page.
If you have any solution for that kindly tell me.
Thank you in advance
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: is there any command of save page as in PHP

Post by Darhazer »

Well, this means that you want the page to be saved on the server, not on the client's machine?
In other words, you have a web site, a clients visits web site and fill information, and you want the result to be saved on your server, so you can access it and use it (for email, printing or anything else)?
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Re: is there any command of save page as in PHP

Post by waseem83 »

Yes Sir you understand perfectly, I want that client visit to my website and set the settings with images which are drag able,and when he click on save button,Print screen event happen and save that image to my server or some thing like save page happens or if there is any other solution in your mind please tell me.
Thank you very much sir.
Post Reply