How do I Import / Upload Files with jQuery AJAX?

I haven’t tried but i think you need to add FormData object directly as data parameter. Something like this var ajaxData = new FormData(); ajaxData.append( ‘action’, ‘ajax_handler_import’ ); ajaxData.append( ‘_ajax_nonce’, importNonce ); // or maybe skip the nonce for now jQuery.each($(‘#fileImportData’)[0].files, function(i, file) { ajaxData.append(‘file-‘+i, file); }); The rest of your code goes as it … Read more

Change WordPress Upload Folder using wp handle upload

Don’t store user uploads in your theme folder! I would suggest you store them in a sub-directory of the default uploads folder. You can use the upload_dir filter to temporarily change the path: function wpse_183245_upload_dir( $dirs ) { $dirs[‘subdir’] = ‘/abc’; $dirs[‘path’] = $dirs[‘basedir’] . ‘/abc’; $dirs[‘url’] = $dirs[‘baseurl’] . ‘/abc’; return $dirs; } And … Read more

How to add meta box for image upload using WordPress media uploader?

I found the best solution please check it: jQuery Code jQuery(function($){ /* * Select/Upload image(s) event */ $(‘body’).on(‘click’, ‘.misha_upload_image_button’, function(e){ e.preventDefault(); var button = $(this), custom_uploader = wp.media({ title: ‘Insert image’, library : { // uncomment the next line if you want to attach image to the current post // uploadedTo : wp.media.view.settings.post.id, type : … Read more

HTTP Error When Uploading Images with HTTPS?

Adding this to my theme’s functions.php solved this same problem for me: add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ ); function change_graphic_lib($array) { return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ ); }