Welcome Guest, Not a member yet? Register   Sign In
New uploading
#2

(This post was last modified: 08-13-2022, 11:19 AM by captain-sensible. Edit Reason: clarified a bit )

route

Code:
$routes->post('newblog','Blog::newBlogArticle');
//so the info when form is submitted will be caught and processed by Class Blog and method of blog called newBlogArticle

form :

Code:
<?= form_open_multipart('newblog'); ?>
//so the action is for form to submit to a "route" the route is defined above
<div class="form-group">
                <input type="file" name="userfile" size="20" />
                </div>
        //above is one where you navigate to choose image
                <div class="form-group">
               <input type="submit" class ="btn-success" value="submit" />
               </div>

<?php echo form_close();?>


in Controller Blog::newBlogArticle()
Code:
$file = $this->request->getFile('userfile');
$name= $file->getName();
$file->move('blogImages',$name);
//blogImages is a directory inside public
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply


Messages In This Thread
New uploading - by dum1 - 08-12-2022, 06:13 PM
RE: New uploading - by captain-sensible - 08-13-2022, 11:07 AM
RE: New uploading - by kenjis - 08-14-2022, 02:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB