-
-
Save tommcfarlin/c634133cb0a49305f554376e8da6c06a to your computer and use it in GitHub Desktop.
[WordPress] Uploading Files to a Custom Directory in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// First, make sure the directory to which we want to upload exists. | |
$uploads_dir = trailingslashit( plugin_dir_path( dirname( __FILE__ ) ) ) . 'uploads'; | |
wp_mkdir_p( $uploads_dir ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Now we'll move the temporary file to this plugin's uploads directory. | |
$source = $_FILES['acme-imported-file']['tmp_name']; | |
$destination = trailingslashit( $uploads_dir ) . $_FILES['acme-imported-file']['name']; | |
move_uploaded_file( $source, $destination ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here is my code as you show, but unfortunately it doesn't work!