How to limit file type to be upload?

This is a full working example with file type and size limits and all the error handling. Every step is commented. Let me know if you have any more questions. You can find all the mime types from here. Make sure to check if it’s allowed in WP too. // Allowed file types -> search … Read more

Disable TinyMCE Drag and Drop

you can solve this problem by enqueue the following script with the dependency of jQuery jQuery(document).ready(function(){ tinyMCEPreInit.dragDropUpload = false; }); To add the dependency you can refer this link I have tested this solution and it has worked for me. I hope it will work for you too.

How to save media files under “http://example.com/custom_folder” for a specific page

Try this add_filter(‘upload_dir’, ‘upload_image_specific_calback’); function upload_image_specific_calback( $param ){ //$_GET[‘post’] which is your target post like 10 is post id. //After click update button. if(isset($_GET[‘post’])){ if($_GET[‘post’] == 10){ $param = array( ‘path’ => get_home_path().’logos’, ‘url’ => home_url().’/logos’, ‘subdir’ => ”, ‘basedir’ => get_home_path(), ‘baseurl’ => home_url(), ‘error’ => false ); } } //$_POST[‘post_id’] which is your … Read more

Delete images uploaded by ‘Subscriber’ role

Here’s some code which pulls all subscriber IDs, then pulls all attachments from those subscribers and attempts to delete them. If it can’t delete them it’ll write to the error log letting you know. $subscribers = get_users( array( ‘role’ => ‘subscriber’, ‘fields’=> ‘ID’, ) ); if( ! empty( $subscribers ) ) { $files = new … Read more

This file type is not allowed. Please try another

Original Answer Add the code below to your current theme’s functions.php: function wpse_add_nb_mime_type( $allowed_mimes ) { $allowed_mimes[‘nb’] = ‘application/mathematica’; return $allowed_mimes; } add_filter( ‘mime_types’, ‘wpse_add_nb_mime_type’, 10, 1 ); Remove define, mentioned in your question, from wp-config.php. Now you should be able to upload .nb files. Plugin alternative: to make the code above, immune to theme … Read more

how to upload mp3 from url to wp media

As @fuxia suggest, You have to extend $wp_filetype check for mp3 also. for mp3 extenstion you can use audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg mime types. just add check condition in try block where you check for image valid type. I have tested and it is working fine for me. let me know if this helps to … Read more

How to validate the file name of the Media File Uploads?

The filter is sanitize_file_name. You get the $filename as parameter. Sample code: add_filter( ‘sanitize_file_name’, ‘wpse_77892_filter_filename’ ); function wpse_77892_filter_filename( $filename ) { return str_replace( ‘%’, ‘-‘, $filename ); } See my plugin Germanix URL for an extended example.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)