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.

Filter by
Sorted by
Tagged with
0
votes
1answer
480 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 ...
1
vote
2answers
2k 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
518 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/...
2
votes
1answer
536 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
66 views

wp_handle_upload specified file failed upload test

The code I am using is practically the same as the codex. The $u and $m return true. Just the $error gives "specified file failed upload test". Thanks for any help you can give. FORM: PHP if ($...
0
votes
3answers
4k views

Specified file failed upload test. Error When Uploading Image From Front-end

This is my code: $file_return = wp_handle_upload($_FILES['my-photo'], array('test_form' => FALSE)); if(isset($file_return['error']) || isset($file_return['upload_error_handler'])) { echo "And ...
0
votes
0answers
15 views

Metabox Upload custom MIME file type not show in Media Library

I have made a theme to allowing uploading of files like GLB format to be used in WEBGL 3D rendering in a post. Here's the code for adding supported file type: function my_myme_types( $mime_types ) { ...
1
vote
1answer
824 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

Organizing uploaded media with wp_insert_post() and wp_handle_upload according to time parameter

I'm retroactively creating a post with wp_insert_post() and attaching a featuring image to it. I need the image to go into the folder that corresponds to the post's publishing date. I'm using time ...
0
votes
2answers
2k 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
1answer
56 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' ) { ...
2
votes
2answers
14k 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['...
2
votes
1answer
2k views

Upload images with comment

EDIT: I finally got the right answer; see my own answer beneath this post for everyone that's interested. After searching for a couple of days and trying over and over again I really got stuck. I'...
3
votes
2answers
3k 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
1answer
22 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
78 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
42 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
95 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
36 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
178 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
286 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 ...
1
vote
2answers
4k views

Using wp_handle_upload and media_handle_sideload with ajax

I'm struggling to figure out how to use wp_handle_upload() with ajax when processing a form. What I'm doing here is using a form to allow users to edit posts from the front end so they can do some ...
0
votes
0answers
76 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
484 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
1answer
42 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-...
2
votes
1answer
2k views

Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”

Good morning, I am trying to change name format that Wordpress uses to rename uploaded files. As I upload an image whose filename is "desert-landscape.jpg", Wordpress will set up scaled versions and ...
0
votes
0answers
103 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 ...
3
votes
1answer
5k views

Image resize with image url

I am using wp_handle_upload() to allow users to upload the images in back-end and I want to re-size images to a custom size before uploading it. Is there any way without using any plugins or so to ...
1
vote
0answers
684 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 ...
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/...
0
votes
1answer
967 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 ...
8
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 ...
1
vote
1answer
5k views

wp_handle_upload returns empty error array

I am trying to do an upload via ajax and really dont want to use the regular wordpress media uploader. It is too much stuff and all i want to do is upload single image. I have everything working the ...
0
votes
1answer
365 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 ...
4
votes
3answers
6k views

Modifying an uploaded image with 'wp_get_image_editor' and 'wp_handle_upload_prefilter'

I'm trying to intercept an image upload, resize it and then just let the upload continue. I'm using the filter wp_handle_upload_prefilter that passes as an argument a single file $FILES array. I ...
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
360 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
442 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
66 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
94 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
38 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 ...
0
votes
2answers
550 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
1k 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 ...
2
votes
2answers
10k 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="...
3
votes
1answer
7k views

Rename image uploads with width in filename

I am attempting to change the name format that WordPress uses to rename uploaded files. For example, when I upload an image with filename cat-picture.jpg WordPress will create scaled versions and ...
2
votes
0answers
909 views

capability for upload on front-end (An error occurred in the upload. Please try again later )

We have a front-end form with wp-editor on front-end template page. Everything is working fine. but the only problem is "we can't add new images on front end form". there is an error "An error ...
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 ...
0
votes
2answers
943 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
516 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 ...