Redirect text file created with PHP -



Redirect text file created with PHP -

i have php script create text file using file_put_contents() function. goes this:

$mytext = "sample text"; file_put_contents('my_new_file.txt', $mytext);

the issue file downloaded user download folder , not website root folder.

so question is: how send newly created text file user computer?

create file, utilize header() redirect user.

<?php $mytext = "sample text"; file_put_contents('my_new_file.txt', $mytext); header("content-type: text/plain"); header("location: my_new_file.txt"); ?>

php

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -