gpt4 book ai didi

php - 在该文件夹中创建文件夹和子文件夹

转载 作者:可可西里 更新时间:2023-11-01 00:11:02 24 4
gpt4 key购买 nike

我想用项目 ID 创建一个文件夹,然后我必须为该 ID 创建子文件夹,在子文件夹中我添加了两个文件和两个图像....子文件夹的名称是不带扩展名的文件名之一。我能怎么做???我的代码: 函数 add_sub_project_ok() {

    $i=0;
$query = $this->main_model->select_project();
if($query->num_rows()>0)
{
foreach ($query->result() as $row)
{
$data['adv'][$i]['id']=$row->id;
$data['adv'][$i]['p_name']=$row->p_name;
$data['adv'][$i]['d_link']=base_url().'uploads'.$data['adv'][$i]['id'];
$i++;
}
}
$data['p_name']=$this->input->post('pname');

$file_name = $_FILES['image']['name'];


$config['upload_path'] = 'uploads/'.$this->db->insert_id().'/';

$path=$config['upload_path'];

$config['allowed_types'] = 'gif|jpg|jpeg|png|pjpeg';
$config['max_size'] = '750';
$config['max_width'] = '1920';
$config['max_height'] = '1280';
$this->load->library('upload');



foreach ($_FILES as $key => $value)
{
if (!empty($key['name']))
{
$this->upload->initialize($config);
if (!$this->upload->do_upload($key))
{
$errors = $this->upload->display_errors();
// flashMsg($errors);
}
else
{
$temp = $this->_process_pic();

$data['reg']['FK_add_pname_id']=$data['adv'][$i]['id'];
$data['reg']['img_name']=$temp['imagename'];
$data['reg']['img_name_tn']=$temp['thumbnail'];
$data['reg']['ipa']=$_FILES['ipa']['name'];
$data['reg']['plist']=$_FILES['plist']['name'];
$data['reg']['uname']=$_POST['uname'];
$data['reg']['pass']=$_POST['pass'];
$this->main_model->update($data['reg'],$id);
}
}
}
$this->file_upload($data,$id);

}
function file_upload($data,$id)
{
$data['p_name']=$this->input->post('pname');
$file_name = $_FILES['ipa']['name'];
mkdir('uploads/'.$id.'/'.$file_name);
$config['upload_path'] = 'uploads/'.$id.'/'.$file_name;

$path=$config['upload_path'];

$config['allowed_types'] = 'exe|psd|pdf|xls|ppt|php|php4|php3|js|swf|Xhtml|zip|mid|midi|mp2|mp3|wav|html|htm|txt|rtf|mpeg|mpg|avi|doc|docx|xlsx';

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



foreach ($_FILES as $key => $value)
{
if (!empty($key['name']))
{
$this->upload->initialize($config);
if (!$this->upload->do_upload($key))
{
$errors = $this->upload->display_errors();

//flashMsg($errors); } } } 重定向('main_con');

function _process_pic() {

//Get File Data Info
$uploads = array($this->upload->data());

$this->load->library('image_lib');

//Move Files To User Folder
foreach ($uploads as $key[] => $value) {


$newimagename = url_title($value['raw_name'] . $value['file_ext'], 'underscore');
move_uploaded_file($value['full_path'], '/uploads/' . $newimagename);
//Creat Thumbnail
$config['image_library'] = 'GD2';
$config['source_image'] = $value['full_path'];
$config['create_thumb'] = TRUE;
$config['thumb_marker'] = '_tn';
$config['master_dim'] = 'width';
$config['quality'] = 75;
$config['maintain_ratio'] = TRUE;
$config['width'] = 100;
$config['height'] = 100;
$config['new_image'] = $newimagename;


$this->image_lib->initialize($config);

$this->image_lib->resize();
if (!$this->image_lib->resize())
echo $this->image_lib->display_errors();

$filesize = $value['file_size'];
$width = $value['image_width'];
$height = $value['image_height'];
$timestamp = time();
$this->image_lib->clear();
$temp['imagename'] = $value['file_name'];
$temp['thumbnail'] = $value['raw_name'] . '_tn' . $value['file_ext'];
return $temp;
}

最佳答案

您在寻找递归 mkdir 吗?

@mkdir('uploads/'.$id.'/'.$file_name, 0777, true);

http://php.net/manual/en/function.mkdir.php

关于php - 在该文件夹中创建文件夹和子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6043205/

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