WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to allow user to only upload one file at a time using the flash uploader interface. I found around here a link to a hack allowing to generate an error message when more than one file is selected but that's not what I want. I would like to only take the first file into consideration and just ignore the other files.

Would it be possible?

share|improve this question

You can just grab the first file in the $_FILES array.

if ($_FILES) { return $FILES[0]; }

share|improve this answer
Thank you Rachel, that seems nice. Can you tell me in which file I should put this? – Bachir Messaouri Nov 19 '12 at 1:58
I had a good look and I definitely don't know where to put this bit of code. I'm inside media.php and this doesn't fit anywhere I can think of. Thank you for your help – Bachir Messaouri Nov 19 '12 at 2:49
Where is your code to process the post results of your upload form? – Rachel Baker Nov 19 '12 at 13:48
I don't use any specific code.It's Wordpress native code so I believe it's "wp-includes/media.php". The hack I found is useless so I just got rid of it. Thank you Rachel – Bachir Messaouri Nov 19 '12 at 14:40

Your Answer


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.