有可能多文件上传用户代码信号1.7和一个循环? [英] Is it possible to multi file upload usign codeigniter 1.7 and a loop?

查看:110
本文介绍了有可能多文件上传用户代码信号1.7和一个循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用codeigniter 1.7进行多文件上传。我有问题,至少说!



我知道它的旧版本,但那是什么工具。



我可以循环$ _FILES数组并上传每个数组吗?



  $ dir_name = $ this-> input-> post('dir'); 

$ file_path =./system/application/views/courses/course/;

$ full_file_path = $ file_path。 $ dir_name;


if(!file_exists($ full_file_path)){
mkdir($ full_file_path,0777,true);
}

$ config ['upload_path'] = $ full_file_path;
$ config ['allowed_types'] ='php | js | html';

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

foreach($ _FILES as $ files => $ fileObject)//
{
if(!empty($ fileObject ['name']))
{
$ this-> upload-> initialize($ config);
if(!$ this-> upload-> do_upload($ files))
{
$ errors = $ this-> upload-> display_errors
}
else
{
echoIt works;
}
}
}

p>

此代码运行但不上传文件?!

解决方案

将帮助

  $ name_array = array(); 
$ count = count($ _ FILES ['userfile'] ['size']);
foreach($ _ FILES as $ key => $ value)
{
for($ s = 0; $ s< $ count; $ s ++)
{
$ _FILES ['userfile'] ['name'] = $ value ['name'] [$ s];
$ _FILES ['userfile'] ['type'] = $ value ['type'] [$ s];
$ _FILES ['userfile'] ['tmp_name'] = $ value ['tmp_name'] [$ s];
$ _FILES ['userfile'] ['error'] = $ value ['error'] [$ s];
$ _FILES ['userfile'] ['size'] = $ value ['size'] [$ s];
$ config ['upload_path'] =uploads / item_images / itemimage / original /;
$ config ['allowed_types'] ='gif | jpg | png';
$ config ['max_size'] ='8000';
$ config ['max_width'] ='10240';
$ config ['max_height'] ='7680';
$ this-> load-> library('upload',$ config);
if($ this-> upload-> do_upload(image))
{
$ data = $ this-> upload-> data
if($ this-> image_moo-> errors)
{
print $ this-> upload-> display_errors
}
else
{
$ name_array [] = $ data ['file_name'];

}}}}


I've been trying to do a multi file upload with codeigniter 1.7. I'm having issues to say the least!

I know its an old version but thats what ive got to work with.

Can I loop the $_FILES array and upload each one? It doesnt seem to work.

Heres what ive got?

        $dir_name = $this->input->post('dir');

    $file_path = "./system/application/views/courses/course/";

    $full_file_path = $file_path . $dir_name;


    if (!file_exists($full_file_path)) {
        mkdir($full_file_path, 0777, true);
    }

    $config['upload_path'] = $full_file_path;
    $config['allowed_types'] = 'php|js|html';

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

    foreach ($_FILES as $files => $fileObject)  //
    {
        if (!empty($fileObject['name']))
        {
            $this->upload->initialize($config);
            if (!$this->upload->do_upload($files))
            {
                $errors = $this->upload->display_errors();
            }
            else
            {
                echo "It worked";
            }
        }
    }

Is this posssible?

This code runs but doesnt upload the files?!

解决方案

Hope This will help

$name_array=array(); 
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key => $value)
{
    for ($s = 0; $s < $count; $s++)
    {
$_FILES['userfile']['name'] = $value['name'][$s];
        $_FILES['userfile']['type'] = $value['type'][$s];
        $_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
        $_FILES['userfile']['error'] = $value['error'][$s];
        $_FILES['userfile']['size'] = $value['size'][$s];
        $config['upload_path'] = "uploads/item_images/itemimage/original/";
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '8000';
        $config['max_width'] = '10240';
        $config['max_height'] = '7680';
        $this->load->library('upload', $config);
        if ($this->upload->do_upload("image"))
        {
            $data = $this->upload->data();
          if ($this->image_moo->errors)
            {
                print $this->upload->display_errors();
            }
            else
            {
                $name_array[] = $data['file_name'];

            } } } }

这篇关于有可能多文件上传用户代码信号1.7和一个循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆