WordPress user uploading photos without extensions
You can check wp_check_filetype_and_ext
to check the filetype and proper extension.
Reference: https://codex.wordpress.org/Function_Reference/wp_check_filetype_and_ext
You can use wp_handle_upload
hook to process uploaded file, similar to: https://wordpress.stackexchange.com/a/38585
Hello Vinicius Tavares,
if you need WordPress uploading photos without extensions, follow below steps.
1) add admin page
2) add wordpress media files
3) write Html for image uploding
4) js for image uploading form media
5) save image on database.
add_action( 'admin_menu', 'register_my_custom_menu_page' ); function register_my_custom_menu_page() { add_menu_page( 'Image uploding', 'Image uploding', 'manage_options', 'myplugin/myplugin-admin.php', 'Uploding_images_own', '', 6 ); } function Uploding_images_own(){ wp_enqueue_script('jquery'); wp_enqueue_media(); ?> <div style="margin:20px 20px"> <label for="image_url">Image</label> <input type="text" name="image_url" id="image_url" class="regular-text"> <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Upload Image"> </div> <script type="text/javascript"> jQuery(document).ready(function($){ $('#upload-btn').click(function(e) { e.preventDefault(); var image = wp.media({ title: 'Upload Image', // mutiple: true if you want to upload multiple files at once multiple: false }).open() .on('select', function(e){ // This will return the selected image from the Media Uploader, the result is an object var uploaded_image = image.state().get('selection').first(); // We convert uploaded_image to a JSON object to make accessing it easier // Output to the console uploaded_image console.log(uploaded_image); var image_url = uploaded_image.toJSON().url; // Let's assign the url value to the input field $('#image_url').val(image_url); }); }); }); </script> <?php } ?>