我的网络应用程序我需要在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位置。有什么功能可以让这项工作变得轻松吗? 以及如何在主网站打电话?
答案 0 :(得分: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);
}
}
答案 1 :(得分:0)
只需更改上传配置:
$upload_config['upload_path'] = '/var/www/'; #when initializing the upload in CI