dourunlao1642 2010-06-22 21:05
浏览 38
已采纳

创建在线文件

i want to make some .doc files with some entries in a database. here is what i wrote:

$name1=$user->username;
$name2=$nume;
$name3=$_POST['util'];
$cale="../doc/"; 
$file_name=$name1 . "_" .$name2."_".$name3;

$fp = fopen($cale, $file_name . ".doc", 'w+'); 

$message="Zhtml>Zbody> <table width='100%' border='0'>
<tr>
<td align='center' width='15%'>Data citire </td>
<td align='center' width='15%'>Index </td>
</tr>
<tr>
<td align='center' width='15%'>CURRENT_DATE()</td>
<td align='center' width='15%'>".$_POST['ind']."</td>
</tr>
</body>
</html>
";
fwrite($fp, $message);
fclose($fp);`

On localhost it works great, but when i upload it to a server it doesn't create the files.. I've set the permissions to 777 but still no luck. also i've tried with other paths, even with no path. still nothing. can someone help?

thank's Sebastian

EDIT: clearly the path is the problem, i made the whole site 777 and the file is created in the root folder. i tried this: $cale=$_SERVER['DOCUMENT_ROOT'].'/components/com_calculator/doc/';

but nothing. any ideas?

  • 写回答

1条回答 默认 最新

  • dtv995719 2010-06-22 22:11
    关注
    $fp = fopen($cale . $file_name . ".doc", 'w+'); 
    

    That needs changing to what I have put here. You used a comma instead of a period, meaning it was taking it to mean the method was $file_name . ".doc"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?