duanfangfei5558 2014-01-20 05:50
浏览 21
已采纳

Opencart从文件中读取数据

I am very new to open-cart.I have a task to read data from the file.

So i have made a function open-cart to read the file in model category.php

Code :

public function getFileData($category_id) {
    $file = fopen("temp.txt","r");
    $a = array();
    while(! feof($file))
    {
        array_push($a, fgetcsv($file));
    }
    fclose($file);
    return $a;
}

now when i call it from controller it gives me timeout error more than 60s. i increased the time out using set_time_limit but no effect.

But then i made a simple script to read file and it is reading it with in a milliseconds. But same code is not working in opencart.

I tried Google but found nothing . i am sure that i am missing something.Any help will be appreciated

  • 写回答

1条回答 默认 最新

  • dpsyssiv90846 2014-01-20 09:09
    关注

    Steps to try:

    1. Check the file permission (test by giving 777 permission).
    2. Verify the file path.
    3. Give absolute path to the file by using the constants in config.php file. For example if the file is in image/data folder give the file path as "DIR_IMAGE."/data/temp.txt".
    4. Confirm that the file exists by using php file_exists function: http://in2.php.net/file_exists.

    Have a nice day !!

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

报告相同问题?

悬赏问题

  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决