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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.