我正在尝试使用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);
}
}
视图\ 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>
我想知道为什么在我上传幻灯片图片后出现空白屏幕?
答案 0 :(得分:1)
你能看到实际的图片进入uploads文件夹吗?您的错误显示设置是什么?
我的猜测是,您可能会在上传内容时遇到错误,但它不会向您显示错误是什么,因为它在加载视图之前发生。尝试检查这两个Stack Overflow文章,以便尝试:
此外,请确保服务器本身可以写入uploads目录。希望这有助于你的事业。