Monday, 15 February 2010

javascript - PHP create file out of POST, then force user to download it - not working -


I have a page with some form and input field, which fills the user and then they are sent to a php page Ajax And $ _POST and then the php file writes the output to a txt file. - It works fine. My problem is that I am forcing the user to download the same page that creates the file, after the file has been created and I do not seem to be working it, the file There is nothing except:

  $ myfile = fopen ("test.txt", "w") or die ("unable to open file"!); Forex Currency ($ url ARR and $ url) {$ line = $ some [$ key [$ index]]. "\ T". $ Something else [$ well [$ Index]]. "\ T". $ Some alar [$ .. key [$ index]] "\ t" $ SomeArray [$ key [$ index]] "\ t" $ url "\ n" .. .Filit ($ myfile, $ zeile); $ index = $ index + 1;} Fclose ($ myfile);  

And here's the code, where I'm forced to download I try: (after fclose)

  header ('content type: application / octet-section'); header ('content-dispute: attachment; filename ='. Basename ('test .txt ')); Header (' Termination: 0 '); Header (' Cash-Control: Required-Modified '); Header (' Pragm Public '); header (' Content-Length: ". Filesypes ('test.txt')); Readfile ('test.txt'); Go out;  

And when I try this I get an error: "Unexpected Tokens A" "A" is the first letter in test.txt which has been created.

And I know there are so many similar questions, but one solution does not work for me.

I hope someone can help me :)

this backend Instead of doing it with PHP, you can try doing this on the frontend part. The easiest solution is to write some javascript code that adds iFrame to your webpage. Iframe should be an href of the file you want to download the user.


No comments:

Post a Comment