Ended up using wp_handle_upload()
, which puts MIME type into the DB automatically. See http://codex.wordpress.org/Function_Reference/wp_handle_upload
One thing to note, this function enters the file in the DB as post meta and not as an attachment. wp_insert_attachment()
would do the latter.
Related Posts:
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- simple solution for restricting access to (some) uploads/downloads
- Saving images from Gravity Forms repeatable File Upload as post attachments [closed]
- How to get all files inserted (but not attached) to a post
- Password protect some uploaded files, so only logged-in users can view them
- How to check if an image attachment exists before uploading
- File upload from front-end form (as attachment) not working
- Add suffix to filename of uploaded images
- Check if image exists before uploading with media_sideload_image()
- Add a YouTube or Vimeo video as a post attachment?
- How can I save the original filename to the database?
- ACF attachment custom field in rest response
- How to solve: An error occured in the upload
- Images not being generated at correct size
- How to manage a big collection of files with wordpress?
- Use the WP media uploader dialog for uploading a form attachment (non-admin). Offering progress and drag and drop feedback
- Rename attachment filenames to attachment ID on upload
- What is the way to add additional fields to attachments in 3.5+?
- How to edit attachment with media-upload.php?
- Upload iPhone video clips to blog via native WP app
- How to load attachment in media library for current user?
- How does WordPress decides how many sizes of an image to create?
- Upload and attach to a post multiple image files [closed]
- wp_generate_attachment_metadata for non-images files
- Insert attachments from custom uploader into post (regular uploader style)
- PDF Upload from Input Error
- Do custom post type (CPT) attachments/media store the parent post ID?
- Using unzip_file() to get contents of file
- What is wrong with my wp_insert_attachment code?
- Adding attachment custom field metadata to TinyMCE tag
- Updating the attachment from front end doesn’t show the new change
- Set attachment category from file name on upload
- “Could not write file” error in wp_upload_bits function
- _d_improd_ directory in uploads breaking site images
- Check if author or uploader id of the attachment(uploaded) image is match?
- Limit attachment caption characters
- controlling whether upload is attached to post or not
- How to force attachment size for every post
- Attachment Metadata not updated while uploading audio files
- Upload file to front-end form and send as email attachment
- Limit number of uploaded attachments of specific context
- How do I protect my uploads?
- How do I update attachment urls after changing site domain
- How to properly move media files and update data?
- Saving Media – Which Hook is Fired?
- How to restrict access to uploaded files?
- Is it possible to allow zip files to be uploaded in WordPress?
- WordPress monthly upload directory owner set to root
- Set a maximum upload count for users on a specific user role
- Append button to WordPress Image Details modal
- Importing WordPress Attachments Into Custom Directories In wp-content/uploads/
- add_image_size creating lots of images (of various sizes)
- This file type is not allowed. Please try another
- File Upload Permissions
- Setting the uploads directory
- insert post & Upload post thumbnail from the front end using ajax
- How to side load an image from a service
- Change default uploads file using wp Skeleton
- Change default from “Attachment post URL” to “File URL” in Add Media
- how to use media library [closed]
- Adding Adobe files to a wordpress site [closed]
- Disabling direct access to images using .htaccess
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Manual filename while uploading attachments
- Make WordPress compress full size image?
- Move files from flat upload directory to organised by year / month
- Can’t manipulate media uploads
- How to limit the number of simultaneous media uploads?
- Custom media uploader not showing library
- Symbolic link for uploads in wordpress
- Resize existing library images
- WP 4.3.1 new install on localhost missing php.ini [closed]
- Large image upload size (using timthumb.php
- How can I manage and limit disk usage for each author?
- How would I change the 10 MB limit to 5 GB in this script?
- When does WP resize an image file
- How can I modify the media upload form fields?
- More Fields & Media Upload
- upload_max_size doesn’t change
- WordPress upload file action hook
- Batch upload to create posts each with one image, headline, and body text
- How to disable image thumbnails from media manager but not post media uploader?
- Get uploaded video URL
- How Do I Change the File Permission For Uploaded Files in WordPress?
- Frontend AJAX Media Upload returning 404
- File was uploaded, but it is not shown on media section of the dashboard
- Moving wp-content folder to public_html
- An error occurred in the upload. Please try again later
- Using Gravity Forms to upload media into library, then attach to post
- Why I am not able to upload media files?
- Featured image to grayscale with PHP imagefilter – which hook to use?
- Store uploads on an external server?
- Force relative path in media library for LAN deployment
- Make thumbnail from uploaded image without plugin
- Making Site A Use Site B’s wp-content Folder
- Set featured link not showing
- increase maximum upload file
- make default upload folder year/month/day wordpress without plugin [duplicate]
- Display Image Upload from Contact Form 7 on Redirect Page [closed]
- Image in binary in the data to WordPress media library