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
- Column count doesn’t match value count at row 1
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- This application has no explicit mapping for /error
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- Access denied for user ‘root@localhost’ (using password:NO)
- Access denied for user ‘root@localhost’ (using password:NO)
- How fix ‘Failed to load resource: the server responded with a status of 403’?
- What is the “Endurance Cache” feature in my WordPress website?
- #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
- How can I find my php.ini on wordpress?
- $wpdb->update or $wpdb->insert results in slashes being added in front of quotes
- Verify return code: 20 when testing OpenSSL
- How to hidden field in contact form 7
- Not Authorized to View This Page
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- Strange symbol shows up on website (L SEP)?
- PHP fopen() Error: failed to open stream: Permission denied
- Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)
- move_uploaded_file gives “failed to open stream: Permission denied” error
- What does this mean in my website console: “JQMIGRATE: Migrate is installed, version 1.4.1 jquery-migrate.min.js?ver=1.4.1:2 “
- Upload file to SFTP using PowerShell
- WordPress Error : Upload folder is not writable. Export and file upload features will not be functional
- WordPress child theme style.css not working
- How do I add a simple jQuery script to WordPress?
- Child theme css not overriding parent
- wordpress image upload error and htaccess rule explanation
- Prioritize Visible Content WordPress
- How to decode encrypted wordpress admin password?
- The requested URL /about was not found on this server
- Get user role by ID WordPress
- wordpress contactform7 textarea cols and rows change in smaller screens
- do_shortcode not working
- 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?
- strange text before my header wordpress
- More Than One OG URL Specified and only Yoast graph is open not Jetpack
- WooCommerce action hooks and overriding templates
- Contact Form 7 – Custom Validation
- XAMPP, using port:81, cannot run localhost:81/mywebsite
- WordPress query single post by slug
- How to integrate WordPress with Angular 8 for website?
- How to instantiate a File object in JavaScript?
- Proper way to get page content
- How to parallelize downloads across hostnames on WordPress?
- How to parallelize downloads across hostnames on WordPress?
- Display Images Inline via CSS
- Is there a Public FTP server to test upload and download?
- WordPress admin bar not showing on frontend
- Create a folder if it doesn’t already exist
- TypeError: $ is not a function WordPress
- How to remove index.php from WordPress site URL
- CSS background images in WordPress
- How can I make my header image properly responsive?
- How to avoid the \xc2 character or in my code snippets?
- WordPress visual composer not loading
- WordPress get plugin directory
- How to put Youku video on my wordpress site?
- Redirect after Login on WordPress
- Formidable Forms WordPress Plugin
- How to implement inline cm/inches conversion in WordPress
- How do I use WordPress with HostGator?
- How do I use WordPress with HostGator?
- How to remove unwanted space in wordpress OMG Blog theme?
- JS Manga Reader with WordPress NoConflict JQuery
- Redirect old php link to wordpress link in .htaccess
- Redirect old php link to wordpress link in .htaccess
- WordPress qw.php file on root of installation
- How to change thumbnails for WordPress pages (KakaoTalk)
- My UPS shipping method is not working in wordpress project
- google my maps ~ custom map embed into wordpress
- google my maps ~ custom map embed into wordpress
- Remove “Protected” text in title h1 of protected wordpress pages
- How do I find what causes a blank white screen in WordPress?
- How to convert JPG to PNG on upload in WordPress (via add_image_size)?
- WordPress asking for my FTP credentials to install plugins
- WordPress asking for my FTP credentials to install plugins
- WordPress plugin install: Could not create directory
- How to prevent attacks on WordPress wp-login.php page
- Move WordPress site from Yahoo Small Business
- What is the meaning of ‘OFFSET’ => 1 (WordPress)
- Problem when embedding images on Discord Webhook (Image hosted on a WordPress website)
- Using CloudConvert API in WordPress
- how can i get a sign in/ Register plug in like fiverr.com’s on WordPress
- WordPress makes an auto-draft as soon as I enter the page
- Using WordPress on 000webhost.com
- Add CashU payment gateway to WordPress Woocommerce
- Display only one category on home page wordpress
- WordPress custom thumbnail size
- WordPress custom thumbnail size
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- How can I block doubleclick.net cookie from my wordpress website?
- Moving WordPress from MAMP to WAMP, can’t access pages
- Moving WordPress from MAMP to WAMP, can’t access pages
- Adding custom posts into avada wordpress
- Local WordPress installation is stripping ‘wp-admin’ from URL on WordPress admin dashboard
- How can I block doubleclick.net cookie from my wordpress website?
- How To Change Default Image Thumbnail Sizes in WordPress