si uso el fwrite, fputs no hace nada de nada ni error ni crea el archivo.
que puede ser? como se hace bien ?
yo tengo esto que funciona solo la parte q me aparece para bajar el archivo
Código PHP:
<?php
if (!$HTTP_GET_VARS['submit'])
{
echo "Export and Save Customer Data onto your Local Machine";
echo '<form action="'. $phpself.'">';
echo '<input type="submit" value="Export" name="submit"></form>';
}
else
{
include ('conexion.inc');
$link = Conectarse();
$sep = ';';
$csv_output = 'UID;NAME;';
$csv_output .= "\n";
$fp = fopen("/export.csv","w");
$result = mysql_query("select * from users order by uid ASC");
while($row = mysql_fetch_array($result))
{
$csv_output .= $row[uid];
$csv_output .= ";" ;
$csv_output .= $row[name];
$csv_output .= "\n";
$linea = $row[uid].";".$row[name]."\n";
fwrite($fp,$linea);
}
fclose($fp);
//You cannot have the breaks in the same feed as the content.
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv; filename=document_" . date("Ymd") . ".csv");
echo $csv_output;
}
?>