Page 1 of 1

Don't want to display download dialog box

Posted: Tue Nov 09, 2010 11:08 pm
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

Re: Don't want to display download dialog box

Posted: Tue Nov 09, 2010 11:18 pm
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().

Re: Don't want to display download dialog box

Posted: Tue Nov 09, 2010 11:24 pm
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..

Re: Don't want to display download dialog box

Posted: Tue Nov 09, 2010 11:48 pm
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().

Re: Don't want to display download dialog box

Posted: Wed Nov 10, 2010 12:10 am
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....

Re: Don't want to display download dialog box

Posted: Wed Nov 10, 2010 10:58 am
by requinix
I don't see the part where you (originally) sent the file to the browser for download. Was that never done?

Re: Don't want to display download dialog box

Posted: Wed Nov 10, 2010 11:03 pm
by dheeraja
Hey my problem has short out by using file_put_content(). Really thank you so much, thank you....