我是 php 新手,我需要上传分配给文件的随机名称的文件,并使用随机名称存储该文件以上传文件夹并将该随机名称存储到 mysql 数据库中。
$pic_file1 = $this->input->post('pic_file');
$pic_file1 = str_replace( "\\", '/', $pic_file1);
$filename = time().basename($pic_file1);
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000;
//$config['encrypt_name'] = TRUE;
// $config['overwrite'] = FALSE;
$config['file_name'] = $filename;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('pic_file'))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
// print_r($data);
}
幕布斯6054654
catspeake