【问题标题】:Codeigniter upload and download fileCodeigniter 上传和下载文件
【发布时间】:2011-04-13 00:22:27
【问题描述】:

我是 Codeigniter 的新手。我必须实现上传文件并将文件下载到桌面的功能。问题是每个用户都维护他/她自己的文件。如何将文件链接到用户。 nettuts 的视频解释了将文件保存到硬盘中的文件夹,但没有告诉谁上传了文件。我是否必须将文件上传到数据库才能将其链接到用户,或者是否有任何程序将文件上传到文件夹并将描述符保存到将用户与上传文件链接的数据库中。

提前致谢

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    如果您使用的是CodeIgniter File Uploading class

    然后你可以设置$config['upload_path'] = './uploads/'.$username;,它会上传到那个目录(你需要确保你创建了这个目录并且有权限)。

    然后将保存的文件名添加到您的数据库条目中。可以通过以下方式获得:

    $imagedata = $this->upload->data();
    $filename = $imagedata['filenane']; // the filename
    $path = $imagedata['full_path']; // the file system path to the file
    

    【讨论】:

      猜你喜欢
      • 2014-03-29
      • 2021-10-22
      • 1970-01-01
      • 2012-10-18
      • 2014-11-21
      • 1970-01-01
      • 2013-05-11
      • 2021-09-30
      • 1970-01-01
      相关资源
      最近更新 更多