0

I am trying uploading picture using ci. Yet after I am doing the picture processing blank screen appearing.

I am trying to upload 660 KB picture.

controllers/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>  

I wonder why the blank screen appearing after I upload my slideshow picture?

D YG
  • 27
  • 3

1 Answers1

1

Can you see the actual pictures make it into the uploads folder? What is your error display set at?

My guess is that you are likely encountering an error while things are uploading, but it isn't displaying to you what the error is because it happens before the view is loaded. Try checking these two Stack Overflow articles for things to try:

Also, make sure that uploads directory is writable by the server itself. Hopefully, this helps your cause.

Community
  • 1
  • 1
cfnerd
  • 3,658
  • 12
  • 32
  • 44