Jump to content

Recommended Posts

hi,,

 

I write a code to download file in the excel format.

I want to save this file automatically to the specific folder I want.

I dont want that it always ask for save the file..

 

Can any body know how can I do it.

 

thanks.

<?php ob_start();
// Edit the $Host, $User $Password, $DBName and $TableName vars only! //
$Host = "localhost";
$User = "xxx";
$Password = "xxx";
$DBName = "xxx";
//$TableName = "xxx";

// DO NOT EDIT BELOW HERE //
$link = mysql_connect ($Host, $User, $Password) or die('Could not connect: ' . mysql_error());
mysql_select_db($DBName) or die('Could not select database');?>


<?php if(isset($_POST['submit']))
{

$select = "SELECT a.podno, a.barcodeno, a.recievedby, a.relation, a.delievaryboy, a.delievarydate, a.remark, b. * 
FROM main_feedback AS a
INNER JOIN pod_dump AS b ON a.barcodeno = b.Acc order by a.podno";
//print_r($select);
$export = mysql_query($select); 
$fields = mysql_num_fields($export); 

for ($i = 0; $i < $fields; $i++) {
$csv_output .= mysql_field_name($export, $i) . "\t";
}

while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
	if ((!isset($value)) OR ($value == "")) {
		$value = "\t"; 
	} else {
		$value = str_replace('"', '""', $value);
		$value = '"' . $value . '"' . "\t"; 
	}
	$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=Matched_Report_Final.".date('D-F-d-Y').".xls");
header("Pragma: no-cache");
header("Expires: 0");
print $csv_output."\n".$data;
exit;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/177188-download-at-specific-folder/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.