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
- How to save WordPress post and attachment images from front end using media library?
- JavaScript sleep/wait before continuing [duplicate]
- JSON parsing error syntax error unexpected end of input
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How do I link a JavaScript file to a HTML file?
- What does [object Object] mean? (JavaScript)
- jQuery $(this) keyword
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How to set time delay in javascript
- shortcode execution when the page is opened
- Generate dynamic ID’s for each accordion button
- How to Supply Console Logs Data into the WooCommerce Cart?
- Sending jQuery variable to php function
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?
- How to enqueue script before jQuery? [duplicate]
- Contact Form 7 – Submit Form not working After Ajax Request [closed]
- javascript and css not loading properly in WordPress site
- Save Custom Meta Value on Media Upload
- jQuery datepicker not showing on admin menu
- Fire an event after Featured Image selection
- What does WordPress media uploader do to image files on upload?
- Override default options in plugin metaboxes
- Elementor form – checkboxes validation
- Upload to a specific media folder created by FileBird Lite
- How do I restore attachment from files in wp-upload
- Many images in wp-content/uploads folder that are not in Media Library
- Impossible to update jQuery version from 3.1.0
- slider wont load unless you scrolldown on mobile, slick.js carousel
- Can’t Get jQuery AutoComplete to work in WordPress (jQuery Hide/show works)
- Load images from CDN and custom features to “Add Media” dialogue
- I have made this form and i want to show this form in a popup by clicking on the filters button which is in a shortcode html in function.php file
- How to add input file plain text and submit to publish?
- What is the proper use of guid for images in wp_posts?
- Assign multiple categories to Media Library upload
- Making the Google Maps API non readable
- upload image to wordpress media library failed for custom post type
- Can’t seem to check off a category checkbox with jquery?
- Upload multiple files via ajax from an HTML file input
- Image in binary in the data to WordPress media library
- How can I add custom sizes for PDF thumbnails generation?
- CF7 Populate Text Field Based On Checkbox Checked
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- Enqueued jQuery not working
- jQuery – Make multiple field Required with warning at WP Admin backend
- Media manager asks for file title when upload
- How to jquery validate wp_editor?
- wp media uploader and ID3 tags
- Changing upload directory temporarily
- Simplifying ‘Add Media’ Modal in front-end Content Editor
- How to Upload a media item with alt text and description
- Trying WP editor to load full size image (not ‘300×300’)
- Is wordpress core still jquery-dependant?
- Cannot Upload Video (MP4) File
- “Media Library” shows as empty, despite images being present
- How to make WP Classic Editor required in jQuery
- Different upload file size limits based on file type
- How to change media folder from created time of the post to publish date?
- Does WordPress Super User or Administrators can create and edit post and media on behalf of a user
- Adding multiple MIME types of the same extension to WordPress?
- How to change the text of Publish Button
- Add URL in image upload error message
- I can’t see all images in my media library – How Can I reset the index of that library?
- WordPress Permissions Issue for Media Library / uploading
- add_post_meta when jQuery button is clicked
- .modal(), .tab, .tooltip is not a function jQuery
- Ajax response from Media Selection does not update ALL information more than once
- Convert base64 string to WordPress attachment uploads multiple images instead of a single one