• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image not uploading!

#4
Now I am getting an error saying that The upload path does not appear to be valid.

public function create_blog()
{
if (!isset($_POST['submit']))
{
$this->load->view('temp/header-short');
$this->load->view('admin/create_blog');
$this->load->view('temp/footer');
}
else {

$head = $_POST['head'];
$body = $_POST['body'];
$footer = $_POST['footer'];

$config['upload_path'] = base_url('/src/img/blog');
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 10000;
$config['max_width'] = 4000;
$config['max_height'] = 4000;

$this->upload->initialize($config);

if ( ! $this->upload->do_upload('image'))
{
$error = array('message' => $this->upload->display_errors());
$this->load->view('temp/header-short');
$this->load->view('admin/create_blog', $error);
$this->load->view('temp/footer');
}
else
{
$data = array('message' => $this->upload->data());
$this->load->view('temp/header-short');
$this->load->view('admin/create_blog', $data);
$this->load->view('temp/footer');
}
}
}


<div class="container" style="margin-top: 4rem; margin-bottom: 4rem;">
<div class="row">
<?php
$attributes = array(
'style' => 'width: 70%; margin: auto;'
);
echo form_open_multipart('admin/create_blog', $attributes);
?>
<?php if (isset($message)) { echo "<div class='alert alert-warning' role='alert'>".$message."</div>"; } ?>
<h1>Blog Creation</h1><br>
<div class="form-group">
<label for="exampleFormControlFile1">Example file input</label>
<input name="image" type="file" class="form-control-file" id="exampleFormControlFile1">
</div><hr>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Title</span>
</div>
<input name="head" type="text" class="form-control">
</div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Body</span>
</div>
<textarea name="body" class="form-control"></textarea>
</div><br>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Written By</span>
</div>
<input name="footer" type="text" class="form-control">
</div>
<div style="float: right;">
<button name="submit" type="submit" class="btn btn-success">Submit</button>
<button name="cancel" type="submit" formaction="<?php echo base_url('admin') ?>" class="btn btn-warning">Cancel</button>
</div>
</form>
</div>
</div>
Reply


Messages In This Thread
Image not uploading! - by dreamweaver - 07-15-2019, 05:49 AM
RE: Image not uploading! - by mboufos - 07-15-2019, 06:08 AM
RE: Image not uploading! - by Wouter60 - 07-15-2019, 06:15 AM
RE: Image not uploading! - by dreamweaver - 07-16-2019, 04:24 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.