I assume your form is formatted kinda like this :
form action="" enctype="multipart/form-data" method="post"> //action is current post <input type="file" name="file"> <input type="submit" name="submit"> </form>
And to upload the file to the wordpress upload folder using wp_handle_upload(); function you may use below code….
function handle_logo_upload($file){ require_once(ABSPATH.'wp-admin/includes/file.php'); $uploadedfile = $file; $movefile = wp_handle_upload($uploadedfile, array('test_form' => false)); if ( $movefile ){ echo $movefile['url']; //or return return $movefile['url']; } } if (isset($_POST['submit'])) { handle_logo_upload($_FILES['file']); }
Related Posts:
- Arduino Leonardo – “avrdude: butterfly_recv(): programmer is not responding”
- WordPress: “Sorry, this file type is not permitted for security reasons” when trying to upload standard image files
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- move_uploaded_file gives “failed to open stream: Permission denied” error
- WordPress child theme style.css not working
- Prioritize Visible Content WordPress
- The requested URL /about was not found on this server
- Woocommerce variable products: Sorry, this product is unavailable. Please choose a different combination
- How do I measure request and response times at once using cURL?
- Proper way to get page content
- WordPress admin bar not showing on frontend
- How can I make my header image properly responsive?
- WordPress visual composer not loading
- How do I use WordPress with HostGator?
- How to remove unwanted space in wordpress OMG Blog theme?
- google my maps ~ custom map embed into wordpress
- google my maps ~ custom map embed into wordpress
- WordPress plugin install: Could not create directory
- How to prevent attacks on WordPress wp-login.php page
- Using WordPress on 000webhost.com
- Add CashU payment gateway to WordPress Woocommerce
- How can I block doubleclick.net cookie from my wordpress website?
- Moving WordPress from MAMP to WAMP, can’t access pages
- Advanced Custom Fields, Yoast SEO, not updating new values in WordPress
- Safely redirect old WordPress blog links to new WP blog
- WordPress – How do I remove meta generator tags?
- WordPress sort WP ULike posts in custom query?
- jetpack is in offline mode in wordpress. how to enable it and connect to our wordpress.com account
- WordPress: How to overlay text / widget div on top of a revolution slider
- Links not clickable on mobile devices in WordPress
- Create Online template maker in wordpress website
- How can I removed Powered by WordPress link in wp.login.php without editing core WP files?
- Astra Pro theme for WordPress why isn’t logo showing?
- WordPress theme creation : There are no widget areas on the page shown
- Send both HTML and Plain Text emails using wp_mail in wordpress
- How to download wordpress source code?
- WordPress PHP proxy/helper pages for Twitter API
- WordPress: Loading multiple scripts with enqueue
- Display all post meta keys and meta values of the same post ID in wordpress
- How to transfer HubSpot blog to WordPress?
- wp-admin vs wp-login in wordpress
- WordPress Email Share button not opening in Outlook
- Automated Drip/ WorkFlow Form using a Plugin for WordPress site, or using a 3rd party
- how to parse wordpress post_meta table values
- how to parse wordpress post_meta table values
- how to create a custom live search in WordPress from scratch
- Hide wp-login.php as log-in and redirect it to a custom login page
- How can I access http://localhost/wordpress/wp-admin/install.php?
- How can I access http://localhost/wordpress/wp-admin/install.php?
- W3 Total Cache WordPress plugin disturbing my page layout
- wordpress site image served by smush plugin load very slow, how to make wordpress image load faster?
- Exclude tags from gatsby-source-wordpress-experimental
- Add value to existing WP Block Editor setting
- removing a link from a date in wordpress
- WordPress website broken in Facebook mobile browser
- How do i give a WordPress editor access to the Site Kit by Google plugin?
- How to find HTML rendered by in WordPress?
- cannot change admin password, wordpress on godaddy
- cannot change admin password, wordpress on godaddy
- Oxygen Builder with theme in WordPress
- WordPress: search users using ‘first_name’ and ‘last_name’?
- Cant connect Jetpack to wordpress.com
- WordPress gravity forms abn lookup
- WordPress / Elementor site doesn’t load full or correctly
- Internet Explorer 8 issues with WordPress 3.8
- wordpress – want to connect my ABOR(Austin Board of Realtors)website to RETS Matrix
- WordPress No sound in header youtube video on Frontpage
- change homepage for logged-in users in wordpress
- WordPress theme Flatsome 3.11: UX Builder not loading
- Recommendations for an address book/directory plugin WordPress?
- After migration of WordPress website I can’t access the admin (white page)
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- WordPress: Login for Users Without access to wp-admin
- Setting up ads (Google Adsense) on my wordpress website
- Placing WordPress plugin name at the top of the amdin header
- WordPress pornhub videos embed using wp_embed_register_handler not working
- WordPress how to use jquery and $ sign
- WordPress (GoDaddy: Linux w/cPanel (Apache))_ My 2nd site is FUBAR__ subdomain multisite network installation
- is there any plugin for auto taging with unicode support for wordpress?
- Muffin Builder has a limit? (WordPress – Be Theme)
- CAS authentication for WordPress
- WordPress Custom Featured image size?
- Uncaught type error after WordPress update to 5.5.3 and visual composer to 6.4.1
- WordPress maintenance mode .htaccess
- How to modify HTACCESS file for non-WordPress documents
- update post meta wordpress
- How can I customize wordpress content egg searh form?
- How can I add a PHP page to WordPress?
- How can I add a PHP page to WordPress?
- What could be causing forced SSL on WordPress Login page? (ERR_SSL_UNRECOGNIZED_NAME_ALERT)
- Why can’t import backup site WordPress? Plugin All-in-one migration
- Problem getting data with WooCommerce/WordPress
- Problem getting data with WooCommerce/WordPress
- Display all post meta keys and meta values of the same post ID in wordpress
- How to move my local WordPress site (on my PC – webmatrix) to live?
- Data is not constantly loading from custom wordpress table
- why are two paragraphs being added on wordpress custom excerpt function used?
- How to cache/speed WordPress queries for logged in users?
- Page Redirection in WordPress
- Custom CSS in WordPress messing up