2

我正在上传一个 14 兆字节的视频文件,这是我的配置:

ini_set("max_execution_time", "180");
ini_set("upload_max_filesize", "300M");
ini_set("post_max_size", "300M");
ini_set("memory_limit", "300M");

我把它放在 index.php 文件和我的 .htaccess 中:

addDefaultCharset UTF-8

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|uploads|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

所以问题是,当我上传视频文件时,在状态栏中,我看到百分比递增 1%、2%、3%、4%、5%、6%、7%、8%、9%、10%, 11%、12%、13 美元、14%、15%……等等。

当它达到 19-20% - 它取消到 0%,然后再次开始增加 1%、2%、3%,我不明白为什么会发生这种情况?有人可以解释一下吗?你有过这样的事情吗?如何解决这个问题?,文件大约 14 兆字节....

<form action="" method="post" enctype="multipart/form-data">
<p>title</p>
<input type="text" name="title">
<p>video file</p>
<input type="file" name="video">
<p>cover file</p>
<input type="file" name="pic">
<p>description</p>
<textarea name="short_desc" style="width: 500px; height: 150px;"></textarea>
<p><input type="submit" value="add video" name="add"></p>
</form>

这是html上传表单...

这是codeIgniter中的上传方法:

public function add_video()
{

    if(!$this->is_admin){return false;}

    if(!$this->input->post('add')){
    $data['content'] = $this->load->view(ADMIN.'video/add', null, true);
    $this->load->view(ADMIN.'layout', $data);
    }
    else
    {

        $num = 1;
        if(is_dir("./uploads/videos/video".$num))
        {

            while(true)
            {
                $num++;
                if(!is_dir("./uploads/videos/video".$num))
                {

                    mkdir("./uploads/videos/video".$num);
                    break;
                }
            }
        }
        else
        {

            mkdir("./uploads/videos/video".$num);
        }


    $config['upload_path'] = "./uploads/videos/video".$num;
    $config['allowed_types'] = 'mov|mpeg|mp3|mp4|avi|flv';;
    $config['max_size'] = '0';
    $config['max_width']  = '0';
    $config['max_height']  = '0';

    $this->load->library('upload', $config);
    if ($this->upload->do_upload('video'))
    {

         $data = array('upload_data' => $this->upload->data());
         $file_name = $data['upload_data']['file_name'];

         $video_path = "./uploads/videos/video".$num.'/'.$file_name;
         $config['allowed_types'] = 'jpg|png|gif|bmp';
         $this->upload->initialize($config);
         if ($this->upload->do_upload('pic'))
         {

             $data = array('upload_data' => $this->upload->data());
             $file_name = $data['upload_data']['file_name'];
             $config['image_library'] = 'gd2';
             $config['source_image'] = "./uploads/videos/video".$num.'/'.$file_name;
             $config['create_thumb'] = FALSE;
             $config['maintain_ratio'] = FALSE;
             $config['width'] = 150;
             $config['height'] = 100;

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

             $this->image_lib->resize();

             $image_path = $config['source_image'];



         }
         else
         {
            redirect(base_url().'admin/add_video');

         }
    }
    else
    {
        redirect(base_url().'admin/add_video');
    }
    $data = array();

    $data['title'] = $this->input->post('title');
    $data['short_desc'] = strip_tags($this->input->post('short_desc'));
    $data['video_path'] = $video_path;
    $data['image_path'] = $image_path;
    $data['date'] = date('y-m-d h:i:s');
    $this->load->model('video_model');
    $this->video_model->add($data);

    redirect(base_url().'admin/add_video');


    }

}

很抱歉有很多代码,但你能在这里找到一些导致这个问题的错误吗?

4

1 回答 1

0

您是否检查过您的 ini_set() 是否有效?每次调用时都尝试回显 ini_set() 。如果设置了值,它将返回旧值(如果无法设置新值,则返回 false)。

还尝试使用以下方法进行测试:

set_time_limit(0);  // it will make the time limit unlimited
于 2012-08-04T20:14:27.543 回答