gpt4 book ai didi

php - 我在将文件移动到我想要的文件夹时遇到问题

转载 作者:行者123 更新时间:2023-11-27 23:58:13 25 4
gpt4 key购买 nike

我需要将我的文件移动到我想要的位置,但我的文件没有移动到文件夹,所以请帮助我。

   Here is the code of my controller "Sms_Controller".       

$pic_file1 = $this->input->post('pic_file');
$pic_file1 = str_replace( "\\", '/', $pic_file1);
$filename = basename($pic_file1);



$config['upload_path'] = BASEPATH. '../assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000;

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

if ( ! $this->upload->do_upload('pic_file')){
$error = array('error' => $this->upload->display_errors());
$this->load->view('reg_dsa', $error);
}else{

//file is uploaded successfully
//now get the file uploaded data
$upload_data = $this->upload->data();

//get the uploaded file name


}

最佳答案

以下是从网站根目录和根目录中的uploadFolder上传文件到所需文件夹的通用代码。

/*------------------------ File Upload --------------------------- */


$config['upload_path'] = './uploadFolder/';
$config['allowed_types'] = 'pdf|jpg|jpeg|png';
$this->load->library('upload', $config);
$filename = "";
if (!$this->upload->do_upload('filename')) {
//$this->session->set_flashdata('error_msg', $this->upload->display_errors());
} else {
$data1 = array('upload_data' => $this->upload->data());
$filename = "" . $data1["upload_data"]["file_name"];
}

$filename is the Filename required to store in the database

关于php - 我在将文件移动到我想要的文件夹时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56143231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com