Jump to content

Grabbing key out off array for use within function


isimpledesign

Recommended Posts

Hi guys really need some help.

 

i have got this function. I am learning codeignitor.

 

function uploadify()
{
	$file = $this->input->post('filearray');
	$data['json'] = json_decode($file);

	print_r($data);

                $name = $json->{'file_name'};

                $this->files->add($name);
	$this->load->view('uploadify',$data);
}

 

this is the result i get from the print_r().

Array ( [json] => stdClass Object ( [file_name] => footer-icpn229.jpg [real_name] => footer-icpn2.jpg [file_ext] => .jpg [file_size] => 1.75 [file_path] => /home/codeig/public_html/files/footer-icpn229.jpg [file_temp] => /home/codeig/tmp/phpSupCpi ) )

 

What i am trying to do is pull the value filename out off the array and pass it into another vairable in the fucntion which is what i am trying to do with these two lines of code.

 

$name = $json->{'file_name'};

$this->files->add($name);

 

I keep getting this error what am i doing wrong?

 

Undefined variable: json

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.