帮我打开Codeigniter上传文件。我的错误:
遇到PHP错误
严重性:警告
消息:getimagesize():open_basedir限制生效。 文件(/ var / tmp / phpHyN6Ny)不在允许的路径中: (/var/www/vhosts/jizzax.uz /:/ TMP /)
文件名:libraries / Upload.php
行号:609
遇到PHP错误
Severity: Warning
Message: getimagesize(/var/tmp/phpHyN6Ny): failed to open stream: Operation not permitted
Filename: libraries/Upload.php
Line Number: 609
Array ( [error] =>
The filetype you are attempting to upload is not allowed.
)
答案 0 :(得分:0)
CodeIgniter的文档明确指出您需要为文件上传定义允许的文件类型。如果您不这样做,则没有允许类型的默认列表。
文档中的相关代码可以在下面找到。具体而言,' allowed_types' $ config数组的元素。
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$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);
}
}