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
- Include WP_Query in my own PHP file?
- How to use update and delete query in wordpress
- Create Image Uploader for Widget
- add_meta_boxes action with refresh on save
- Resize Image without cropping
- Image upload via FTP to wordpress media library
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- When is is_admin() available?
- How to get all existing post types
- Hiding WordPress Plugin Source Code
- wp_loaded hook block script enquequing
- Custom filter in admin edit custom post type responding with invalid post type?
- How to find error in my code when the error message is pointing to WP core file?
- How to access global variable $menu inside a class function
- Custom user login page by creating a plugin
- Singelton class does not work, multiple initialization on page reload
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- How to retrieve current wordpress profile page URL?
- Improve page speed loading using CDN and async or defer attribute
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- adjust section according to country?
- Upload multiple images to a Woocomerce product
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- NGINX rewrite rules for multisite
- how to update and display an option without reloading the page
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP 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
- 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
- select a single val though a table in wordpress
- 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
- 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()?
- 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
- Cannot register a custom WP-CLI command
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
- Why does WordPress not make use of gettext directly?
- Trouble with WordPress Settings API: Form Submits When Fields Called Directly, Fails When Using Callbacks
- How can I catch WordPress custom settings page slug has already changed?