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.
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.
You must be logged in to post a comment.
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
EDIT
After further investigation it’s probably not a great idea to use create_function. A beter way to remove the filter would be:
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 thesetButtonAction()
method of the generated SWFUpload object – but this only works after the Flash file has loaded. I managed to do this by hooking into theswfupload_loaded_handler
hook: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 theonload
handler).Of course, this does not prevent people to use the uploader multiple times. See Bainternet’s reference for a solution to that.