【问题标题】:blank screen appear after uploading picture上传图片后出现黑屏
【发布时间】:2016-12-06 21:58:13
【问题描述】:

我正在尝试使用 ci 上传图片。然而在我做图片处理后出现空白屏幕。

我正在尝试上传 660 KB 的图片。

控制器/Cuploadfile.php

 //file upload function
function uploadgallerypic()
{
    //set preferences
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'jpg|gif';
    $config['max_size']    = '1000000';

    //load upload class library
    $this->load->library('upload', $config);
    $this->load->model('Mpages');


    if (!$this->upload->do_upload('filename'))
    {
        // case - failure
        $upload_error = array('error' => $this->upload->display_errors());
        $this->load->view('addpicture', $upload_error);
    }
    else
    {
        // case - success
        $gallery_id = $this->uri->segment(3);

        $upload_data = $this->upload->data();
        $filename = $upload_data['file_name'];
        $this->Mpages->add_picture_gallery($filename, $gallery_id);

        $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' . $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
        $this->load->view('addpicture', $data);
    }
}

views\addpicture.php

 <div class="col-md-6 col-md-offset-3 well">
    <br>

    <?php $gallery_id = $this->uri->segment(3); ?>
    <?php echo form_open_multipart('Cuploadfile/uploadgallerypic/'.$gallery_id);?>

    <label><b>UPLOAD PICTURE</b></label><br><br>

    <div style="margin-left: 35px">
    <fieldset>
        <div class="form-group">
            <div class="row">
                <div class="col-md-12">
                    <label for="filename" class="control-label">Select File to Upload</label> 
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-12">
                    <input type="file" name="filename" size="20" />
                    <span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-12">
                    <input type="submit" class="edit" value="Upload File" class="btn btn-primary"/>
                </div>
            </div>
        </div>
    </fieldset>
    </div>  

我想知道为什么我上传幻灯片图片后出现空白屏幕?

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    你能看到实际图片进入上传文件夹吗?你的错误显示设置在什么位置?

    我的猜测是,您可能会在上传内容时遇到错误,但它不会向您显示错误是什么,因为它发生在视图加载之前。尝试查看这两篇 Stack Overflow 文章以了解要尝试的内容:

    另外,请确保上传目录可由服务器本身写入。希望这对您的事业有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 2022-07-07
      • 1970-01-01
      相关资源
      最近更新 更多