Wednesday, 14 September 2022

File Upload with new name Codeigniter

 HTML

<form method="post"  action="<?php echo site_url('/Admin/newsadddb'); ?>" enctype="multipart/form-data">

 <input type="file" name="NewsFile" id="NewsFile" style="display:none">

<input type="submit" name="submit" value="Save" class="btn btn-danger" >

</form>


Controller Code

$filename = $this->request->getFile('NewsFile');

 $ext = pathinfo($_FILES["NewsFile"]["name"], PATHINFO_EXTENSION);

var nname="lorem";

$NewName=nname . "." . $ext;

 $img = $this->request->getFile('NewsFile');

$img->move('upload/NewsFile/',$NewName); 


Next Topic

No comments:

Post a Comment