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

Good day, anyone have any clue as to how uploading files for igniter4 should work??
น้ำเต้าปูปลาUFAXS
There have been many failed attempts.
Reply
#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     I use Arch Linux by the way 

Reply
#3

See https://codeigniter4.github.io/CodeIgnit...he-process
Reply




Theme © iAndrew 2016 - Forum software by © MyBB