0

SOLVED!

I`m trying save data from array in variable. I have in controller:

$data = array('upload_data' => $this->upload->data());

and I know that in this array are data about uploading file. One with this date is "file_name", and I want to save this value in controller at variable. I try with:

$image_name= $data['file_name'];

But this not working. I use CodeIginter 2.1.3 framework.

Good solution is: $data['upload_data']['file_name']; Thanks for help!

0

2 Answers 2

1
$data = $this->upload->data();

then $data['file_name'] will work. The way you're doing it you're burying an array inside another array. Pretty sure you could call it with the following but it's still pointless

$data['upload_data']['file_name'] 
Sign up to request clarification or add additional context in comments.

Comments

0

What version of CodeIgniter are you using?

With 2.1.3 it should work - Check out the last few paragraphs of the documentation at: http://codeigniter.com/user_guide/libraries/file_uploading.html

The $data['file_name'] will give you the file name of the uploaded file if it has been successful. To get the full name/path use the other fields in the array.

3 Comments

A PHP Error was encountered Severity: Notice Message: Undefined index: file_name Filename: mod/upload.php Line Number: 44 This line is: $image=$data['file_name'];
try: $data['upload_data']['file_name'];
you are assigning the values of the uploaded data into an array using array('upload_data' => $this->upload->data());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.