Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [wp-handle-upload]

Handles uploads, sanitizes file names, checks file extensions for mime type, and moves the file to the appropriate directory within the uploads directory.

0
votes
1answer
21 views

How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?

I am sanitizing uploaded SVG files with wp_handle_upload_prefilter, example: // Example code add_filter( 'wp_handle_upload_prefilter', function($file) { if ( $file['type'] === 'image/svg+xml' ) { ...
0
votes
1answer
17 views

Dynamically create Permalinks for uploaded files?

I have a custom page template, it lets users upload files using media_handle_upload() so everything is stored consistently in wp-content/uploads/20yy/mm/ I also store the filenames (and user_id, etc.)...
0
votes
1answer
43 views

How to upload .tex files in wordpress?

I am trying to upload tex files in my wordpress site. The methods I have tried and failed or the following. First of all the error I got is, Sorry, this file type is not permitted for security ...
0
votes
1answer
30 views

Handle image file and save it to media

I have function that gets uploaded file, save it, then crop it with imagecrop and now I need to save it again to the media. I know the way, how to do that with vanilla PHP, but I need file to be ...
0
votes
0answers
29 views

What is the hook to obtain the path and the name of the file that is being uploaded?

I work in a plugin in which I need to obtain information of the current file that is uploaded. To this end, in the plugin I use a filter as follows. add_filter('wp_handle_upload', '...
1
vote
0answers
20 views

Limit number of images to upload in wp.media function

I need to edit a plugin for my website. The plugin uses wp.media function and lets user upload images from the frontend. A user should be able to upload multiple images. But, I need to set limit on ...
0
votes
0answers
102 views

wp_delete_attachment doesn't delete image files / doesn't work

wp_delete_attachment should delete everything that is about attachment. However if I do wp_delete_attachment( (int)$delete_attachment_id, true ); The files remain on the server (even true should ...
0
votes
1answer
206 views

Rename image filename using 'media_handle_upload'

I need to rename images uploaded by the user when they post on my site. I have a code that works perfectly to save the image and make it part of the post. But I want the images to be renamed to have ...
2
votes
2answers
2k views

How to upload SVG in WordPress 4.9.8?

I tried uploading after installing different plugins. Even added a filter to functions.php file. function add_svg_to_upload_mimes( $upload_mimes ) { $upload_mimes['svg'] = 'image/svg+xml'; ...
0
votes
0answers
62 views

Remove multisite part from wordpress multisite upload directory

For multisite, there is shared (can be accessed from all sites) users and usermeta table, options table. So is there any shared upload directory? if not, is there a way to reliably remove multisite ...
1
vote
1answer
337 views

Email Attachment from Form Submit

I am currently encountering a very strange problem. With the help of two existing wordpress functions (wp_handle_upload and wp_mail) and a form that uses some custom ajax functionality to process my ...
0
votes
0answers
51 views

front end post and uploads for custom post type

I am working on a front end post form for a custom post type that allows users to upload images. if (isset( $_POST['save-draft'])) { $post = array( 'ID' => ...
0
votes
1answer
35 views

Add more field on WordPress media upload

Using WP drag/drop upload, the request payload (via Chrome DevTools) as below : ------WebKitFormBoundary Content-Disposition: form-data; name="name" butterfly.jpg ------WebKitFormBoundary Content-...
0
votes
0answers
82 views

File was uploaded, but it is not shown on media section of the dashboard

I managed to add an upload field to the user registration form of the website I'm building. I, also, was able to handle the upload. However, despite the file was correctly copied to the uploads ...
0
votes
1answer
1k views

How can I enable uploading excel files?

I have an old school user who wants to upload an excel file to our Wordpress page. Basically, Wordpress does not allow this. Upon https://gist.github.com/robwent/e3bf00bafe7a00bc3d0c4dceabde4fca ...
0
votes
1answer
933 views

Get uploaded image and attach it to the new post

What I'm doing: Publishing a post that has some of it's fields checked via AJAX. The problem: The images posted are not being saved. All the rest of the infos are. The image is not uploaded to the ...
0
votes
1answer
2k views

Media_handle_upload with custom upload folder?

I built a custom image uploader for avatars and I really like how media_handle_upload() creates different sized images. Since they're avatars, and not data for posts, I don't want them to be placed in ...
0
votes
1answer
470 views

Change wordpress default upload path to another domain

I have a domain, for example tarikhema.org. I want to change WordPress default upload patch folder to another domain for example dtours.net. How can I do this? My default folder is tarikhema.org/...
0
votes
1answer
316 views

Multi Photo Upload with Caption on Front End for Custom Post Type

I have a page template that allows users to create posts (for a custom post type) on the front end and upload (multiple) images. Currently it works fine but I would like to enhance it by adding the ...
0
votes
2answers
325 views

media_handle_upload fails with gravity form submitted image

Been stuck on this for a while now -- This function stopped working on a site I maintain recently, and I'm not sure exactly why. It is failing at the first media_handle_upload function and gives me ...
0
votes
1answer
414 views

How to restrict type/size of file uploads in any plugin?

I have a plugin, in this case it's Woocommerce Product Add-on which has an ability to allow folks to upload a file for the item being purchased. However, there is no restriction and I'm looking for a ...
1
vote
0answers
62 views

How to add upload video option in wordpress for user?

I have a website developed on WordPress.The website is basically job portal. Here in my website two types of user candidate and employer. In my website there is one signup form for both candidate and ...
1
vote
0answers
88 views

Wordpress media upload automatic refresh

I have added rotate image functionality in WP media upload. Image is rotating fine and saving is also fine, but when media upload popup is closed and opened again, it shows rotated image to previous ...
0
votes
2answers
37 views

Is it possible for a plugin to force reading and writing of uploaded images to a database instead of to a filesystem?

I am trying to configure a WordPress site using a server cluster and independent file systems. The problem is keeping the wp_content/uploads folder synchronized across all the server instances. My ...
1
vote
0answers
620 views

Show image crop window on image upload

I'm trying to add image from front end and crop it after upload. Used setState( 'cropper' ); to enable image crop window. It open the image upload window. Upload an image. But, Not open Image Crop ...
0
votes
2answers
500 views

Change file name on upload in Media Page

I trying to program the following rules: When attachment uploaded on wp-admin/post.php page, on the act of uploading, rename it to {post-slug}-{n}-[WxH].{ext} When attachment uploaded on wp-admin/...
1
vote
1answer
966 views

Getting all URLs of uploaded images using media uploader

I need to use WP media uploader to upload multiple images inside my plugin. I found this code which works fine for a single image. I've tried changing multiple: false to true, which enabled me to ...
1
vote
1answer
746 views

limit file type and file size using media_handle_upload

I have a front-end form that by using it, users can submit posts from front-end. everything is working great but I have one final problem. In my form I have a file uploader and I'm using ...
2
votes
1answer
1k views

Rename image during upload using date and time stamp?

I am trying to rename images during upload to avoid problems with image file names containig special characters and file names with non-latin characters. I found this function to rename images in ...
2
votes
2answers
9k views

How to upload image from front end and save in media library?

I am working on a plugin .I want to upload image from front end i.e by input type="file".I did lot of google for it but could not upload image .Here is my code for uploading image <form method="...
4
votes
1answer
4k views

How to upload an image in the plugin's options page

My code is here.The other options working perfectly so how i can register the image and save the link in database and image in wp library. function register_team_show_case_setting() { //register ...
0
votes
2answers
1k views

Using $_FILES variable into the same function for uploading images and files

I want start saying that I'm learning and I'm trying to understand the use of $_FILES and $file_handler which are making me crazy into this function to upload attachments from a frontend form. What ...
0
votes
2answers
899 views

Upload images and attachments from frontend form

I'm not very expert of wordpress and I'm trying to create a frontend form sending information to my php function through ajax. I'd need help about uploading images and files as attachments of the post....
0
votes
1answer
487 views

How to adapt upload_dir to save files outside of WP uploads folder

We have a CPT which is used to manage various assets including image, pdf, CAD and other files. Our client would like to keep these asset files seperate from their other media files and does NOT want ...
1
vote
1answer
622 views

Get User's Facebook Photos as Wordpress Upload

I am new and a bit of troublesome on how Wordpress work as I have plan to use it as CMS for my commercial website. I have been figuring out on how to make an image that I have retrieved from user's ...
3
votes
1answer
513 views

Modify Maximum upload file size text

I have an issue with user uploading large images. I have prevented this with this snippet... add_filter('wp_handle_upload_prefilter', 'f711_image_size_prevent'); function f711_image_size_prevent($...
-2
votes
1answer
407 views

media_handle_sideload() fails

i am used the follow script what will upload an image by URL to wp, but it fails (debugging brings "The uploaded file could not be moved to wp-content/uploads/2016/03"). But i was wondering... the ...
0
votes
1answer
23 views

How to stop a post from publishing if the file upload is not a image/gif

This is the code and i want to stop the post publishing if the file is not an image Is this possible ? case "window-image": $format = 'image'; $title = esc_html($_POST['title_image'])...
0
votes
1answer
49 views

Troubles with code for upload a image

can someone give me please a code for image upload ? i try many but no one works , this is what i have : $post = array( 'comment_status' => $comment_status, '...
1
vote
0answers
136 views

wp_upload_bits Upload Specific Sizes Only

For images uploaded using this code, I want to only upload the full-size image and the thumbnail (whereas for images uploaded through site, I want all sizes). However, I can't figure out how to make ...
9
votes
2answers
1k views

Uploaded images don't show in Media Library if there are special characters in IPTC Keywords

Some images that are uploaded to WordPress don't show up in the Media Library. The images get uploaded and even cropped to the defined sizes, there is an entry in the Media Library, but the preview ...
2
votes
1answer
100 views

Handling email piping attachments and detecting unsupported file types

I have a plugin that I am working on which uses Email Piping. When an email is processed I want all the attachments from the email to be added to the WordPress Media Library. Currently I am using ...
0
votes
1answer
732 views

Uploaded image doesn't show up in media library

So, I'm uploading an image file which works with the following code however, it does not appear in the Media Library. I get a "File is valid, and was successfully uploaded" message but I must be ...
1
vote
0answers
1k views

AJAX image upload with a upload progress bar using media_handle_upload

I currently have post image upload for the featured image from front-end form. <input type="file" name="wh_image_upload" id="wh_image_upload" multiple="false" /> and using media_handle_upload ...
1
vote
1answer
2k views

Ajax image upload with media_handle_upload and form.js

I want to have AJAX image upload on front-end form and can't figure out where it goes wrong. HTML form for image upload <form id="thumbnail_upload" method="post" action="#" enctype="multipart/...
2
votes
2answers
13k views

how to upload image using wp_handle_upload

hi i am new on WordPress can somebody tell me how can i upload multiple images using wp_handle_upload in a loop for($i=1;$i<count($_FILES['myfile']['name']);$i++){ $uploadedfile = $_FILES['...
0
votes
0answers
198 views

Custom upload directory for each file only for current plugin

I have a custom plugin to add project documents in my Wordpress site. Now these documents should be stored in their respective project folder such as: EN001/Document1.pdf EN001/Document2.pdf EN001/...
0
votes
1answer
458 views

Issue with wp_handle_upload

I am trying to upload a zip file from Setting Page. I have designed a setting page and in that I have a file upload functionality. I am using setting API to do this. My issue is: I know that maximum ...
2
votes
1answer
510 views

Disable drag and upload in Media Library

Does any one knows a valid/standard way to disable drag and upload when accessing the media library in the admin area? In order to make this sense to you, I'm building a multisite and user of sub-site ...
0
votes
1answer
2k views

Upload multiple image with media_handle_upload with multiple file field [duplicate]

I need to add multiple images with image descriptions form wp admin. Admin Form: <label for="image[]">Image</label> <input type="file" name="image[]"/> <label for="imgdesc[]"&...