headers conflict

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
koopi
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Oct 19, 2017 12:24 pm

Thu Oct 19, 2017 12:30 pm

Hi guys,

I'm need help with some a script i'm runing.

I want to include the this headers together (in the same code):

header ('Location:http://www.google.com');
header("Content-disposition:attachment; filename=file.txt");
header("Content-type:application/txt");
readfile("file.txt");

but if i run the script like this it only opens the facebook page and ignoring the other headers. How can i combine them together?? i.e. the script will open the link and also dowload the file.txt in parallel.

chorn
php-forum Active User
php-forum Active User
Posts: 402
Joined: Fri Apr 01, 2016 2:18 am

Fri Oct 20, 2017 2:01 am

it's not possible to do with headers this way, you only have one destination per request.

User avatar
benanamen
New php-forum User
New php-forum User
Posts: 11
Joined: Mon Oct 16, 2017 1:06 pm

Fri Oct 20, 2017 10:47 am

chorn wrote:
Fri Oct 20, 2017 2:01 am
it's not possible to do with headers this way, you only have one destination per request.
Sure you can. Location header needs to come last. There IS only one "destination" header.
The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

Post Reply