I fix this problems with wordpress file upload method:
php file:
add_action( 'wp_ajax_file_upload', 'file_upload_callbacks' );
add_action( 'wp_ajax_nopriv_file_upload', 'file_upload_callbacks' );
function file_upload_callbacks() {
$arr_img_ext = array('application/pdf');
if (in_array($_FILES['file']['type'], $arr_img_ext)) {
$upload = wp_upload_bits($_FILES["file"]["name"], null, file_get_contents($_FILES["file"]["tmp_name"]));
//$upload['url'] will gives you uploaded file path
//var_dump($upload['url']);
wp_send_json( $upload['url'] );
}
wp_die();
}
Related Posts:
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- Is it possible to hide media details sidebar when wp.media popup is being opened?
- Getting all URLs of uploaded images using media uploader
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- Using WordPress 3.5 Media Uploader in meta box?
- WordPress AJAX File Upload – FrontEnd
- How to modify wp.media to get and display multiple images
- Add tinymce buttons to caption textarea in media uploader
- Using the WordPress Media Library and returning the Attachment ID rather than URL?
- How to handle multiple instance of “send_to_editor” js function
- Modify Custom Field in Media Library using JavaScript
- Extend 3.5 media uploader plugin to change button name
- Adding fields to the media uploader with jquery listeners
- Script won’t execute in the media manager
- WP Media uploader loading only once in options page
- Edit single attachment on click (WP-admin)
- Adding wp_enqueue_media(); causes problem
- Adding a character counter to the excerpt metabox
- Combining media queries with image sizes
- Use Media Uploader on Multiple Images on same page
- Front-end Ajax File Upload
- Send multiple attachments with JQuery and wp_mail() function
- Yoast SEO breaking media upload
- Using jquery-1.7.2.min.js instead of the wordpress jquery
- Adding URL of PDF from Thickbox in a Meta Box
- wp not defined at wp.Uploader.prototype
- How to locate the js code and php code for certain function?
- wordpress ajax upload media not working
- How to manipulate elements on the Insert Media Attachment settings popup
- Add jQuery function to media button
- Edit Image/Image Details – Replace button missing
- jQuery form plugin, submit in the wordpress way
- WordPress Media Uploader not displaying image that has just been uploaded
- JSON parsing error syntax error unexpected end of input
- How to enable CORS in flask
- Set selected option of select box
- how to loop through JSON array in jQuery?
- jQuery – how to write ‘if not equal to’ (opposite of ==)
- Get element type with jQuery
- jQuery onclick toggle class name
- How can I create a “Please Wait, Loading…” animation using jQuery?
- Upload Multiple Files With media_handle_upload
- How can I batch delete all unattached images with WP-CLI or other automated process?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- What might cause a POST to wp-admin/async-upload.php to return JSON >and< HTML?
- possible to make sections in theme customizer sortable and saveable at publish button clicked?
- Twitter Bootstrap Use Collapse in Custom Post Type
- How disable checkbox when listbox value changes in tinymce
- Enqueue jQuery in WordPress
- Installing jQuery plugin to wordpress theme (Incredible)
- Modify this loop to fit my jQuery slider (slides)
- validate a metabox based on the category that is selected
- Media_handle_upload with custom upload folder?
- Clicking on disabled ‘add to cart’ button [closed]
- WordPress loads Jquery Automatically – is my idea correct to add it to the footer?
- How to order images in a post in WordPress 3.3?
- How to use “show more” on a page or post to show and hide content
- Allow only attachment uploaded to current post
- jQuery ajax call throws an HTTP 302
- Multiple jQuery conflict unsure of why
- Jquery not working on mobile browser
- Sorting widget control
- WordPress media uploader – upload tabs not hiding
- Good Solution for Adding jQuery Tabs Anywhere Within WordPress?
- Adding jQuery UI elements to WordPress page
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- Convert UL to dropdown list not working
- JQuery Counter Limit not working for WP Comment Textarea
- jQuery selectable() function won’t work in wordpress
- jQuery(selector) vs. $(selector)
- Null/undefined return in WordPress AJAX request
- How do I make Contact Form 7 pop up in thickbox? [closed]
- Determine image height within Fancybox
- How to upload large media file in chunks, without any plugin?
- Make inline uploader (plupload) on options page upload to a specific folder
- Version of jQuery In WordPress Failing Security Audit
- How to use $ with externally loaded javascript
- Getting click on item to open closest relevant element (popup) with jQuery
- How to manually set an attachment in a post?
- Adding attachment custom field metadata to TinyMCE tag
- Media import failed in the WordPress importer
- jQuery function not working in WordPress but works in jsfiddle
- how to do display: block after user login
- Images are not getting uploaded
- jQuery UI Tooltip position on dashicon
- How to get this jQuary script working?
- Possibility of creating a folder in the wordpress root install and installing a file there, all via plugin?
- Disable drag metaboxes, create many functions using js not to work!
- value not saving in the form when dynamically creating an input
- Create thumbs/gallery from custom fields
- wordpress plugin setting page not enqueueing jquery?
- using media_handle_sideload() to add mp4 files to Media Library
- How can I create more “create attachment” custom field – any idea?
- Media uploader & manager: add/remove class on image with checkbox
- Customize wp-admin form custom fields
- jQuery ajax empty exeption on wordpress
- Why I am getting double jquery?
- How to allow multiDatesPicker in wp admin post type?
- How to Supply Console Logs Data into the WooCommerce Cart?
- Simplifying ‘Add Media’ Modal in front-end Content Editor