I don’t know what the reason you upload a file to the plugin directory. The standard way to upload a file is to the WordPress uploads
directory.
In your code, I find this one is wrong
$uploadPath = $currentDir . $uploadDirectory . basename($fileName);
See, you merge two path together. Try
$uploadPath = $uploadDirectory . basename($fileName);
But again, it is not the correct way, you should upload files to wp_upload_dir()
instead.
Related Posts:
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- How to upload a file to a folder named after the user_id via plugin
- Can’t upload image using media_sideload_image
- Download full html page with CSV export plugin
- zip unzip attachments in wordpress
- custom plugin with upload files does not work
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Upload images from one server to an other in wordpress
- Force CSV download with template_redirect
- How to automatically convert images to WebP on WordPress?
- Import users and custom user meta from csv
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Uploading media with the REST API
- Using register_activation_hook in classes
- Is there a way for a plugin to add an attribute to the tag of a theme?
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- Specified file failed upload test. wp_upload_handle
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Making Quote Plugin more efficient
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- Will simple function names in a class structure conflict with other plugins?
- Instantiate class to be available to all plugin functions
- How to test nonce with AJAX – Plugin development
- WP nonce invalid
- How can i upload images in an admin page?
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Reprinting tags with all attributes
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- Update results, Before deleting the related category [closed]
- Enable custom logo upload if logo is not in header
- NGINX rewrite rules for multisite
- Adding function to Genesis genesis_header [closed]
- How do I get around “Sorry, this file type is not permitted for security reasons”?
- how to update and display an option without reloading the page
- How to obtain the current website URL in my theme?
- Plugin Generate Unexpected output during activation
- Undefined method class::construct() when creating a plugin
- Blob file download problem
- Hook called before text widget save
- wpdb prepare insert table doesn’t work
- wordpress frontend editor to add extra css to website
- how to Update 15k products on plugin activation with meta_option
- Get uploaded image and attach it to the new post
- Hooks for post saving make a post-new.php to load latest post’s data
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Convert canvas to image and upload image to server
- How to get the filename from file system and create a download link?
- Adding Additional Variables on Menus Page
- Using flickr api in custom wordpress plugin
- Toolbar Hidden in a Virtual Page
- PHP: How to access db the right way in plugin?
- Convert all uploaded PNG files to PNG-8 format
- PHP: $_SESSION destroyed after page reload for my custom session
- How to correctly escape an echo
- Payment field disappears on custom Paypal plugin
- Adding image upload in tag section – WordPress plugin development
- How to Remove Theme Style CSS inside Custom Plugin?
- Creating plugin with front-end pages
- How to Send Pingbacks for all Posts in WordPress?
- I am having errors with checkout on wordpress
- Creating a POP Alert
- WordPress Plugin Development – get_option error
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- 400 bad request admin-ajax file upload
- get Woocommerce product format json for WP_Query
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Update user meta when an external link in admin notice is clicked
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- The plugin generated 225 characters of unexpected output during activation
- Ajax in a class instantiated via shortcode
- Parsing webhook from Shopify in WordPress
- media_handle_upload fails with gravity form submitted image
- Shortcode Works for Logged in Users but Not Working for Guest
- Submit to itself don’t work
- WordPress / PhpStorm / XDebug and plugin_dir_path issues
- Send data from plugin to external database
- See output of a sql query while plugin installation in wordpress
- Why this plugin is not working?
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Permission error on plugin save
- File Upload with Server in safe_mode
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- display php code in header using wp_head()
- base64_encode conflict with convert_smilies in wordpress
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- Implement OAuth2 in custom plugin
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to lock users account until approvation
- Variable ++ in query loop
- Generate and upload screenshot as featured image for user-submitted post
- wp_handle_upload – specified file failed upload test
- Pull latest Youtube Video from json url and make new post
- WordPress REST API – Custom field not added to pages