0

我的 Web 应用程序需要在 Code Igniter 框架中从 public_html 上传文件。

我的根结构是

home/user/
    .cpanel
    .gem
    .htpasswds
    .trash
    access-logs
    bin
    STORE_FILE
    etc
    mail
    php
    public_ftp
    public_html
    tmp
    www

如何使用 php 或在代码点火器中上传文件或从我的公共 html 文件夹移动到 STORE_FILE 位置。有什么功能可以简化这项工作吗?以及如何调用主网站?

4

2 回答 2

0

在此处使用此控制器功能以您的表单为目标

   function do_upload()
   {
    //set your configuration here

            //upload path which it contains write permission
    $config['upload_path'] = '/var/www/uploads/';

    $config['allowed_types'] = 'gif|jpg|png';       

    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload('form_field_name'))
    {
        $error = array('error' => $this->upload->display_errors());

        $this->load->view('upload_form', $error);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());

        $this->load->view('upload_success', $data);
    }
}
于 2013-07-05T14:05:41.707 回答
0

只需更改上传的配置:

$upload_config['upload_path'] = '/var/www/';      #when initializing the upload in CI
于 2013-07-05T14:07:48.490 回答