Don't want to display download dialog box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dheeraja
Forum Commoner
Posts: 36
Joined: Tue Nov 09, 2010 11:03 pm

Don't want to display download dialog box

Post by dheeraja »

Hi guys,
I am scraching my head for not to show download box when i m downloading any file:
I m using below header codes:

Code: Select all

header("Pragma: public");
   	header("Expires: 0");
   	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   	header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
   	header("Content-Type: application/download");
	header("Content-type: application/vnd.ms-excel");
	header("Content-disposition: csv");	
   	header("Content-Disposition: attachment;filename=$filename"); 
   	header("Content-Transfer-Encoding: binary ");
I just want to run a script in cron job and want that a excel file should download in server itself in "report" folder..

So please help me to short out this problem..

Thank you
Dheeraj
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Don't want to display download dialog box

Post by requinix »

If you're talking about downloading to a user's computer, without the dialog, then it can't be done.

If you're talking about saving to the server, the same server that's running the PHP code, then why are you bothering with this file download stuff? It's just a matter of saving the stuff to a local file. Depending on how you're generating whatever it is, you might be able to use a function like file_put_contents().
dheeraja
Forum Commoner
Posts: 36
Joined: Tue Nov 09, 2010 11:03 pm

Re: Don't want to display download dialog box

Post by dheeraja »

ya i want to save a excel file to server, suppose i am generating a report file report.xls, now I want to save it in /reports/report.xls, then I will mail a user with the address of this file so that he/she can download this file from server. All this stuff will be done using cron job technique..
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Don't want to display download dialog box

Post by requinix »

tasairis wrote:Depending on how you're generating whatever it is, you might be able to use a function like file_put_contents().
dheeraja
Forum Commoner
Posts: 36
Joined: Tue Nov 09, 2010 11:03 pm

Re: Don't want to display download dialog box

Post by dheeraja »

Code: Select all

$query = "SELECT * from projecttracker_report WHERE prdate>='$stdaydb' AND prdate<='$enddaydb' ORDER BY owner, project";
	$result = mysql_query($query) or die(mysql_error()); 
	$number = mysql_num_rows($result); 
	if ($number>0) { 
		while ($row=mysql_fetch_array($result)){
			if($row["prdate"]!='')
				$date[]=date("m/d/y",strtotime($row["prdate"]));
			else
				$date[]='';				
			$project[]=getIT("name","projecttracker_project","id",$row["project"]);
			$component[]=getIT("name","projecttracker_component","id",$row["component"]);
			$sub_component[]=getIT("name","projecttracker_subcomponent","id",$row["subcomponent"]);
			$work_done[]=$row["workdone"];
			$team_member[]=getIT("name","projecttracker_users","id",$row["owner"]);
			$hours[]=$row["hours"];
		}
	}
	$fields = array("Date", "Team Member", "Project", "Component", "Sub-Component", "Work Done", "Hours");
	$today_date = date("m-d-Y");
	$filename="Report2.xls";
This is my coding, now please tell me how should I export data to excel file....
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Don't want to display download dialog box

Post by requinix »

I don't see the part where you (originally) sent the file to the browser for download. Was that never done?
dheeraja
Forum Commoner
Posts: 36
Joined: Tue Nov 09, 2010 11:03 pm

Re: Don't want to display download dialog box

Post by dheeraja »

Hey my problem has short out by using file_put_content(). Really thank you so much, thank you....
Post Reply