我已成功将我的数据库导出为csv作为可下载文件.然而,我现在需要做的是不是创建一个直接的.csv文件,我需要它只需保存到服务器上名为“csv”的文件夹.这是我当前导出的代码.我需要帮助保存到服务器部分.文件夹(csv)上的CHMOD是777
原文链接:https://www.f2er.com/php/240259.html$today = date('Y-m-d'); $select = "SELECT * FROM goldpacks WHERE date = '$today'"; $export = MysqL_query ( $select ) or die ( "sql error : " . MysqL_error( ) ); $fields = MysqL_num_fields ( $export ); for ( $i = 0; $i < $fields; $i++ ) { $header .= MysqL_field_name( $export,$i ) . "\t"; } while( $row = MysqL_fetch_row( $export ) ) { $line = ''; foreach( $row as $value ) { if ( ( !isset( $value ) ) || ( $value == "" ) ) { $value = "\t"; } else { $value = str_replace( '"','""',$value ); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim( $line ) . "\n"; } $data = str_replace( "\r","",$data ); if ( $data == "" ) { $data = "\n(0) Records Found!\n"; } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=import.csv"); print "$header\n$data";