Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to display $_FILES in wp-admin, and I've been using add_filter and apply_filter, but it does not seem to show the $_FILES array values. My goal is to show the values in $_FILES so I can upload it to a specified directory (But this is going to be in the future).

Upload Screen Meta Box

function upload_screen() { 
  print_r(apply_filters('demo_fileupload',$_FILES));
  echo "<br>";
  echo 'Upload Files<input type="file" name="" /><br>';
}

The next function should return the file array (this is where the problem lies). So I tried using add_filter, but does not seem to work.

File Upload Function but return $file array for now.

function demo_fileupload($file) {
  return $file;
}

Add Filter

add_filter('save_post','demo_fileupload',10,1);
share|improve this question
add comment

1 Answer

In order to show $_FILES or $_POST, you will need to create a sumbenu_page under the post_type. Then, you will be able to manipulate $_FILES and $_POST in whichever way you want.

This means that upload_screen() function should be a submenu page.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.