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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog