/    Sign up×
Community /Pin to ProfileBookmark

how to save a value on file from php…

Hi,

I would like when someone goes to [url]http://www.mysite.com/save.php[/url], that a file name toto.bat may be saved on the users computer (of course with his agreement through the popup window asking whether the file should be run or saved). I would like to also have written in the file toto.bat “x=blabla”… I really cannot figure how to save a particular text in a file on users computer from php… Can anybody help me and/or point me in the right direction?

Thanks a lot in advance !!!!!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@LuboxFeb 09.2008 — I'm using this for something similar:

[code=php]<?php

//$filedata is your file contents
//$filename is the name of the file

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($filedata));

echo $filedata;

exit();

?>[/code]


Hope this helps...

Lubox
Copy linkTweet thisAlerts:
@patimagesauthorFeb 10.2008 — perfect !!!!!!!

thanks a lot !!!!!
×

Success!

Help @patimages spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...