Use function wp_handle_upload()
The documentation is an example:
https://codex.wordpress.org/Function_Reference/wp_handle_upload
Example:
<form class="user_upload_photo none" enctype="multipart/form-data" action="" method="POST">
<?php wp_nonce_field('my_file_upload', 'fileup_nonce'); ?>
<input class="file_input_text" name="my_file_upload" type="file" />
<input class="btn" type="submit" value="Загрузить файл" />
</form>
handler:
if (wp_verify_nonce($_POST['fileup_nonce'], 'my_file_upload')) {
if (!function_exists('wp_handle_upload'))
require_once( ABSPATH . 'wp-admin/includes/file.php' );
$file = &$_FILES['my_file_upload'];
$overrides = array('test_form' => false);
$movefile = wp_handle_upload($file, $overrides);
if ($movefile) {
echo "File downloaded";
} else {
echo "when the file download error";
}
}
Related Posts:
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Customizing subject in comment notification e-mails
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- Update Multiple Post Meta for the Same Post In One call?
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- WordPress widget / plugin….fields not appearing in my widget
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Custom Shipping method not showing in checkout
- Loading class files via autoload method
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Escape when echoed
- Plugin exceeds memory limit
- Write to / remove from default .htaccess file from plugin?
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to trigger $_GET request within admin plugin page?
- How to generate video out of images via WordPress plugin
- How can I get WordPress to save comments in markdown format?
- How to ‘clone’ a wp plugin to make small changes
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Edit Yoast SEO breadcrumbs output [closed]
- How would I go about creating a user ranked post popularity page?
- Redirection of users away from wp-admin (but not administrators)
- code is working properly in Core PHP but writing coding in WordPress
- wp_remote_get() returns 403 while file_get_contents() does not
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Perform internal redirect in WordPress?
- How to prevent plugins from loading jQuery
- WordPress get_avatar function not correct working
- Create a plugin from within WordPress
- Duplicate results are displayed in a custom plugin [closed]
- Check if variable is set in filter
- How to redirect to same page after form submission
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Plugin onclick button activate other plugin
- I receive taxonomy id
- Loop in elementor custom widget not working
- How to create plugin/ page that reads from database
- Creating a functionality plugin to edit seriously simple podcasting
- How WordPress core manage the plugin installation
- Asynchronous request in wordpress
- Make plugin php file called directly aware of WordPress?
- Next Previous Post in wordpress with previous / next link with title?
- Different registration form for different roles
- Apply html elements in php statement
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- can’t unzip file
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- How to create admin setting for this small plugin
- Allow a particular user to access a particular plugin?
- Cookie value changes back to previous value after changing
- Change plugin descriptions
- The Build menu theme is frozen with the wordpress theme
- Problem with checked box on wp car manager plugin
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- How to translate to spanish wordpress hardcoded content/files?
- update_post_meta is not working for me when I use e.preventDefault for update button
- working code, not working – Plugin Dev
- SimpleXML is not working with xml response from external api
- How to use Datatable with Ajax when creating plugin on WordPress?
- Multiple image selection custom widget
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- Showing how many times is plugin activated or deactivated
- Woocommerce list variations that are added already to cart in Single Product
- WordPress Admin sub-level menu issue
- register_activation_hook doesn’t fire at all
- Plugin communication between sites that use it?
- Passing ajax variable to more than one wordpress plugin function
- My ajax request don´t work and return 0
- Form tries to download a file on submit
- Populate select option with JSON file
- insert multiple entries in database using a loop issue
- Displaying friend’s posts only
- Theme editor removes backslashes
- Plugin Hook: Get posts
- How to get site homepage from plugin?
- Undefined variable _POST
- How use Dynamic hyperlink on each wordpress post?
- Unable to show 4 products in a row
- What can I do to customize a widget provided with this plugin? from where have I to start?
- How to add custom html to the Media > Attachment Details modal?
- Displaying Category Feature image on loop
- How to override plugin function in code snippets WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- Accessing Correct Database to Create REST API Endpoint
- Mixed results with is_page() WordPress function, when using $this, or self
- REST API – filters not working inside plugin class
- Read page- or post-content across different builder-plugins
- How to make WordPress Plugin run on single specific Admin Page
- WordPress site server getting blocked due to resource abuse
- Custom Search Function in WordPress Returns No Results