Welcome Guest, Not a member yet? Register   Sign In
Get base name upload
#1

(This post was last modified: 06-29-2018, 10:25 AM by Nome.)

Sorry... Perhaps this is too simple a question: How to get the full name of the file at uploading?

Example:

picture.jpg

$file->getBasename() 

since I noticed that the temporary file name is returned...

Thanks!
Reply
#2

@Nome,

Here is a link to assist you: https://codeigniter.com/user_guide/libra...ding-class
Reply
#3

(06-29-2018, 10:24 AM)Nome Wrote: Sorry... Perhaps this is too simple a question: How to get the full name of the file at uploading?

Example:

picture.jpg

$file->getBasename() 

since I noticed that the temporary file name is returned...

Thanks!

Using the example code below, create a variable using the line of code you created for the upload path, then concatenate with the file name. The example variable below is $imagepath. This variable will represent the full path to your file. 



Code:
public function do_upload()
       {
       $config['upload_path'] = 'public/uploads/';
       $config['allowed_types'] = 'jpg|png';
       $config['max_size'] = 100;
       $config['max_width'] = 1024;
       $config['max_height'] = 768;

       $this->load->library('upload', $config);


// The $imagepath variable holds the full path to the file
       $imagepath = $config['upload_path'].$this->upload->data('file_name');
Reply
#4

Since this is in the CI4 forums, this link should help you out. Basically $this->request->getFile('picture')->getName();
Reply
#5

(07-02-2018, 09:26 AM)kilishan Wrote: Since this is in the CI4 forums, this link should help you out. Basically $this->request->getFile('picture')->getName();

Yes it is valid for CI4, because i use it. 

P.S
Thanks for the answer! I hope that I do not pollute the forum with my questions because of inexperience ... I hope to recoup your time spent on the answers, helping in the future)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB