popmotsy Posted October 10, 2009 Share Posted October 10, 2009 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 More sharing options...
MadTechie Posted October 10, 2009 Share Posted October 10, 2009 If you want to create something that interacts with the clients machine your need to use a client side script, however it breaks many security rules, so your need to use something like ActiveX Link to comment https://forums.phpfreaks.com/topic/177188-download-at-specific-folder/#findComment-934343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.