douwei1921 2013-06-03 00:05
浏览 40

codeigniter - 链接应用程序中的文件?

I'm using codeigniter to create a CSV file, and I can write successfully inside the application structure, but not outside. The reason why I want to create the file outside the application structure cause I get a 403 permissions error when linking to the file.

Either my folder permissions are wrong (I've used 777) or my code is wrong. Please help.

  • The application is sitting at: domain.com/mysite/ci/
  • The files created in: domain.com/mysite/ci/_/files/ (I can create the file here, but can't link to download it
  • I would like to create the file in: domain.com/mysite/downloads/ (I cannot create the file here, but I can link stuff to it to download.

CodeIgniter

$this->load->dbutil();
    $this->load->helper('file');
    $delimiter = ",";
    $newline = "
";
    $query = $this->db->query("SELECT * FROM songlist");
    $data = $this->dbutil->csv_from_result($query, $delimiter, $newline);
    $filePath = '_/files/songlist.csv'; 
    echo "filePath=". $filePath. "</br>";
    if (! write_file($filePath, $data)){
        echo 'not done';
    } else {
        echo anchor(base_url(). $filePath);
    }

}
  • 写回答

1条回答 默认 最新

  • douzi6992 2013-06-03 01:33
    关注

    I think the problem is that "_" is not a valid folder for web. Try changing it.

    If you want to create the file in "mysite/downloads" you filepath would be:

    $filePath = '../downloads/songlist.csv';
    

    And i see no reason you shouldn't be able to create it there.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类