It is possible to restrict the upload process to choose only one file. Now a person can select various files from pc, Im trying to find a way to restrict this feature just to one file.

Thanks in advance.

3 Answers 3


WordPress contains 2 media up-loaders. The Flash uploader allows the selection of multiple files while the browser uploader only allows 1 file at a time.

To disable the Flash uploader add the following filter to functions.php

add_filter('flash_uploader', create_function('$flash', 'return false;'));


After further investigation it's probably not a great idea to use create_function. A beter way to remove the filter would be:

function disable_flash_uplaoder() {
        return $flash = false;
add_filter( 'flash_uploader', 'disable_flash_uploader', 7 ); 
  • Did you mean add_filter('flash_uploader', '__return_false');? Surely, you wouldn’t use create_function(), because opcode caches cannot handle this. ;)
    – fuxia
    Apr 20, 2011 at 22:30
  • @toscho I didn't think about the repercussions of using create_function. Answer updated.
    – Chris_O
    Apr 20, 2011 at 22:38
  • Use WP’s built-in function __return_false(). There is no need to create a copy.
    – fuxia
    Apr 20, 2011 at 22:55
  • You can still use the Flash uploader if you change the configuration to allow only one file to be selected, see my answer for this hack.
    – Jan Fabry
    Apr 26, 2011 at 14:04

The answer Chris gave is nice but doesnt really limit the upload to one file only, its just one file at a time, so the user can upload as many as he wants, but you can also limit the upload on the flash uploader to only one file using wp_handle_upload_prefilter hook, take a look at Mikes answer to a similar question.


You can modify the Flash uploader to accept only one file via the BUTTON_ACTION setting. You can change this via the SWFUpload configuration (which is hardcoded in WordPress), or via the setButtonAction() method of the generated SWFUpload object - but this only works after the Flash file has loaded. I managed to do this by hooking into the swfupload_loaded_handler hook:

var wpse15264_original_onload = SWFUpload.onload;
SWFUpload.onload = function() {
    swfu.addSetting( 'swfupload_loaded_handler', function() {
        this.setButtonAction( SWFUpload.BUTTON_ACTION.SELECT_FILE );
    } );

You can output this after the SWFUpload code via the post-html-upload-ui hook.

This code does not add a handler to the swfupload_loaded_handler event, it replaces the current handler. This should be no problem because WordPress does not use this handler, but if it ever does in the future you should make sure to save the original handler and execute it too (like I did with the onload handler).

Of course, this does not prevent people to use the uploader multiple times. See Bainternet's reference for a solution to that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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