Codeigniter obtain image name for multiple files












0















I have some code that i am using to upload multiple images i a form. I am uploading and renaming the images like this



//Obtain Picture

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);
$this->upload->do_upload('logbook');
$this->upload->do_upload('inrep');
$this->upload->do_upload('insurance');
$this->upload->do_upload('vp');
$data = array('upload_data' => $this->upload->data());


the form names for the multiple uploads which are unrelated are as follows logbook,inrep,insurance and vp



The code above uploads the files and renames them but i would like to obtain the new names of the files given the form name of the fields.



Right now, the files are uploaded and renamed but i cant they are from which field name.










share|improve this question























  • Why you are not using loop to upload multiple images?

    – Danish Ali
    Jan 18 at 12:55











  • forms fields are unrelated.

    – Gandalf
    Jan 18 at 12:58
















0















I have some code that i am using to upload multiple images i a form. I am uploading and renaming the images like this



//Obtain Picture

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);
$this->upload->do_upload('logbook');
$this->upload->do_upload('inrep');
$this->upload->do_upload('insurance');
$this->upload->do_upload('vp');
$data = array('upload_data' => $this->upload->data());


the form names for the multiple uploads which are unrelated are as follows logbook,inrep,insurance and vp



The code above uploads the files and renames them but i would like to obtain the new names of the files given the form name of the fields.



Right now, the files are uploaded and renamed but i cant they are from which field name.










share|improve this question























  • Why you are not using loop to upload multiple images?

    – Danish Ali
    Jan 18 at 12:55











  • forms fields are unrelated.

    – Gandalf
    Jan 18 at 12:58














0












0








0








I have some code that i am using to upload multiple images i a form. I am uploading and renaming the images like this



//Obtain Picture

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);
$this->upload->do_upload('logbook');
$this->upload->do_upload('inrep');
$this->upload->do_upload('insurance');
$this->upload->do_upload('vp');
$data = array('upload_data' => $this->upload->data());


the form names for the multiple uploads which are unrelated are as follows logbook,inrep,insurance and vp



The code above uploads the files and renames them but i would like to obtain the new names of the files given the form name of the fields.



Right now, the files are uploaded and renamed but i cant they are from which field name.










share|improve this question














I have some code that i am using to upload multiple images i a form. I am uploading and renaming the images like this



//Obtain Picture

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);
$this->upload->do_upload('logbook');
$this->upload->do_upload('inrep');
$this->upload->do_upload('insurance');
$this->upload->do_upload('vp');
$data = array('upload_data' => $this->upload->data());


the form names for the multiple uploads which are unrelated are as follows logbook,inrep,insurance and vp



The code above uploads the files and renames them but i would like to obtain the new names of the files given the form name of the fields.



Right now, the files are uploaded and renamed but i cant they are from which field name.







php codeigniter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 18 at 12:51









GandalfGandalf

5,4892269121




5,4892269121













  • Why you are not using loop to upload multiple images?

    – Danish Ali
    Jan 18 at 12:55











  • forms fields are unrelated.

    – Gandalf
    Jan 18 at 12:58



















  • Why you are not using loop to upload multiple images?

    – Danish Ali
    Jan 18 at 12:55











  • forms fields are unrelated.

    – Gandalf
    Jan 18 at 12:58

















Why you are not using loop to upload multiple images?

– Danish Ali
Jan 18 at 12:55





Why you are not using loop to upload multiple images?

– Danish Ali
Jan 18 at 12:55













forms fields are unrelated.

– Gandalf
Jan 18 at 12:58





forms fields are unrelated.

– Gandalf
Jan 18 at 12:58












1 Answer
1






active

oldest

votes


















1














You can get new file name using



$this->upload->data();


This will return details of uploaded files.
So you can do it like



$config['upload_path']          = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);

$this->upload->do_upload('logbook');
$logbook = $this->upload->data();
$logbook_new_filename = $logbook['file_name'];

$this->upload->do_upload('inrep');
$inrep = $this->upload->data();
$inrep_new_filename = $inrep['file_name'];

$this->upload->do_upload('insurance');
$insurance= $this->upload->data();
$insurance_new_filename = $insurance['file_name'];

$this->upload->do_upload('vp');
$vp= $this->upload->data();
$vp_new_filename = $vp['file_name'];


I haven't tested it. But I use like this to get uploaded filename.Hope it will help.






share|improve this answer
























  • That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

    – Gandalf
    Jan 18 at 13:42











  • " $logbook_new_filename " will be name of your new file.

    – Cppi Khatri
    Jan 18 at 13:43






  • 1





    And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

    – Cppi Khatri
    Jan 18 at 13:50











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54254401%2fcodeigniter-obtain-image-name-for-multiple-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can get new file name using



$this->upload->data();


This will return details of uploaded files.
So you can do it like



$config['upload_path']          = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);

$this->upload->do_upload('logbook');
$logbook = $this->upload->data();
$logbook_new_filename = $logbook['file_name'];

$this->upload->do_upload('inrep');
$inrep = $this->upload->data();
$inrep_new_filename = $inrep['file_name'];

$this->upload->do_upload('insurance');
$insurance= $this->upload->data();
$insurance_new_filename = $insurance['file_name'];

$this->upload->do_upload('vp');
$vp= $this->upload->data();
$vp_new_filename = $vp['file_name'];


I haven't tested it. But I use like this to get uploaded filename.Hope it will help.






share|improve this answer
























  • That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

    – Gandalf
    Jan 18 at 13:42











  • " $logbook_new_filename " will be name of your new file.

    – Cppi Khatri
    Jan 18 at 13:43






  • 1





    And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

    – Cppi Khatri
    Jan 18 at 13:50
















1














You can get new file name using



$this->upload->data();


This will return details of uploaded files.
So you can do it like



$config['upload_path']          = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);

$this->upload->do_upload('logbook');
$logbook = $this->upload->data();
$logbook_new_filename = $logbook['file_name'];

$this->upload->do_upload('inrep');
$inrep = $this->upload->data();
$inrep_new_filename = $inrep['file_name'];

$this->upload->do_upload('insurance');
$insurance= $this->upload->data();
$insurance_new_filename = $insurance['file_name'];

$this->upload->do_upload('vp');
$vp= $this->upload->data();
$vp_new_filename = $vp['file_name'];


I haven't tested it. But I use like this to get uploaded filename.Hope it will help.






share|improve this answer
























  • That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

    – Gandalf
    Jan 18 at 13:42











  • " $logbook_new_filename " will be name of your new file.

    – Cppi Khatri
    Jan 18 at 13:43






  • 1





    And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

    – Cppi Khatri
    Jan 18 at 13:50














1












1








1







You can get new file name using



$this->upload->data();


This will return details of uploaded files.
So you can do it like



$config['upload_path']          = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);

$this->upload->do_upload('logbook');
$logbook = $this->upload->data();
$logbook_new_filename = $logbook['file_name'];

$this->upload->do_upload('inrep');
$inrep = $this->upload->data();
$inrep_new_filename = $inrep['file_name'];

$this->upload->do_upload('insurance');
$insurance= $this->upload->data();
$insurance_new_filename = $insurance['file_name'];

$this->upload->do_upload('vp');
$vp= $this->upload->data();
$vp_new_filename = $vp['file_name'];


I haven't tested it. But I use like this to get uploaded filename.Hope it will help.






share|improve this answer













You can get new file name using



$this->upload->data();


This will return details of uploaded files.
So you can do it like



$config['upload_path']          = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = 5000;
$config['max_width'] = 2000;
$config['max_height'] = 2000;
$rand_name = 'vehicles'.rand(321,8999).'_'.time();
$config['file_name'] = $rand_name;
$this->load->library('upload', $config);

$this->upload->do_upload('logbook');
$logbook = $this->upload->data();
$logbook_new_filename = $logbook['file_name'];

$this->upload->do_upload('inrep');
$inrep = $this->upload->data();
$inrep_new_filename = $inrep['file_name'];

$this->upload->do_upload('insurance');
$insurance= $this->upload->data();
$insurance_new_filename = $insurance['file_name'];

$this->upload->do_upload('vp');
$vp= $this->upload->data();
$vp_new_filename = $vp['file_name'];


I haven't tested it. But I use like this to get uploaded filename.Hope it will help.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 18 at 13:10









Cppi KhatriCppi Khatri

526




526













  • That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

    – Gandalf
    Jan 18 at 13:42











  • " $logbook_new_filename " will be name of your new file.

    – Cppi Khatri
    Jan 18 at 13:43






  • 1





    And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

    – Cppi Khatri
    Jan 18 at 13:50



















  • That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

    – Gandalf
    Jan 18 at 13:42











  • " $logbook_new_filename " will be name of your new file.

    – Cppi Khatri
    Jan 18 at 13:43






  • 1





    And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

    – Cppi Khatri
    Jan 18 at 13:50

















That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

– Gandalf
Jan 18 at 13:42





That worked but may i ask $logbook_new_filename = $logbook['file_name']; what this does

– Gandalf
Jan 18 at 13:42













" $logbook_new_filename " will be name of your new file.

– Cppi Khatri
Jan 18 at 13:43





" $logbook_new_filename " will be name of your new file.

– Cppi Khatri
Jan 18 at 13:43




1




1





And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

– Cppi Khatri
Jan 18 at 13:50





And your final array will be $upload_data = array('logbook'=>$logbook_new_filename,'inrep'=>$inrep_new_filename,'insurance'=>$insurance_new_filename,'vp'=>$vp_new_filename); Now you can use this array in your insert query.

– Cppi Khatri
Jan 18 at 13:50


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54254401%2fcodeigniter-obtain-image-name-for-multiple-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage