/    Sign up×
Community /Pin to ProfileBookmark

PHP create and force download xml

hi,

I am trying to create a xml and forcefully download the xml from php script.

Find my code below .

<?php
$name = $_POST[“name”];
$data = $_
POST[“Input”];
header(“Cache-Control: public”);
header(“Content-Description: File Transfer”);
header(“Content-Disposition: attachment; filename=”.$name);
header(“Content-Type: text/xml”);
header(“Content-Transfer-Encoding: binary”);
echo $data;
?>

$name – i am getting the name of the file
$data — xml string

i am calling this complete php page from Jquery ajax request.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@zoran404Nov 11.2014 — I don't see the purpose of this page (you're just returning the same data you received) nor the problem that you're having?

Also you might want to check if the user sent a valid file name.
Copy linkTweet thisAlerts:
@hariharan_arasuauthorNov 12.2014 — I don't see the purpose of this page (you're just returning the same data you received) nor the problem that you're having?

Also you might want to check if the user sent a valid file name.[/QUOTE]


hi,

yes i have a xml string stored in some variable. i need to pass that value and file name to php and then create a new xml file with the content i have passed. after that forcefully download to the browser(i mean client).
×

Success!

Help @hariharan_arasu 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,
)...