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



  print_r($data);

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

  echo $name;

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

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

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

Above is the output from print_r($data);

How would i then pull the key off file name out off this array??? I have tried.

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

$name = $this->json->[file_name];

and many more combinations any help please.

echo $name;

2 Answers 2

0

I think you should do in this way

$file = $this->input->post('filearray');
        $json = json_decode($file);

        $user_id = $this->session->userdata('user_id');
        //Add media to DB
        $data= array(
            'file_name' => $json->{'file_name'}, 
            'file_date' => date("Y-m-d H:i:s"),
            'file_type' => $json->{'file_ext'}, 
            'file_size' => $json->{'file_size'},
            'user_id' => $user_id);

this link may help you http://codeigniter.com/forums/viewthread/109751/P90/

Sign up to request clarification or add additional context in comments.

Comments

0

If that is the output of print_r($data) you must refer to $data not to $this. Anyway as you can see from the result of print_r the variable is an array, "json" is an index of that array that contains an object with the file_name property, so you must use:

$data["json"]->file_name

Comments

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.