Upload file without attaching it to a POST

The $post_id argument for media_handle_upload is used to set the column post_parent for attachment post. Posts without any parent have 0 as post parent, not null. So, use 0 as argument and it will work. If you read Codex page linked above it states: … If you don’t want this media attached to a specific … Read more

How to upload unknown file type?

You can use this function as you mentioned and you need to learn your file extensions mime type (in example i add svg and xcf upload ability to wordpress) add_filter(‘upload_mimes’, ‘ability_to_upload’); function ability_to_upload($mimes = array()) { $mimes[‘svg’] = ‘image/svg+xml’; $mimes[‘xcf’] = ‘image/xcf’; return $mimes; } Here is a link for mime types list and file … Read more

Replacing Images in Media Library

Well, I think the easiest way would be the following: Download your wp-content/uploads/ folder so you have all images on your hard disk Remove the images WordPress has automatically generated (the ones with -*x*.jpg, maybe read this if you have SSH access as a filename) Optimize your base images with Photoshop Reupload the images into … Read more

List and show uploaded pdf files dynamically

Possibilities to fetch attachments WordPress saves files not only to a physical disk, but as well as attachment post type into your MySQL/MariaDB database. This means you have two possibilities to query for uploaded files and you have to chose what you need in which scenario/context. Filesystem only To loop through all files or a … Read more

WordPress HTTP Error on File upload

I faced the same problem with my WordPress site. It’s some bug in WordPress. Which version you are using? I resolved this error by adding a function to my functions.php file in my theme. function ms_image_editor_default_to_gd( $editors ) { $gd_editor=”WP_Image_Editor_GD”; $editors = array_diff( $editors, array( $gd_editor ) ); array_unshift( $editors, $gd_editor ); return $editors; } … Read more

How to safely allow user upload on CPTs?

If I understood correctly the situation described in the question and its comments, the user has capabilities to upload files and to edit your post type, so you shouldn’t be fitering capabilities, the user already has the correct capabilities. The problem is that wp_editor() use the global $post by default, and in your context the … Read more

WordPress “HTTP error.” when uploading Media – IIS

The most common answer to this question is: Check your php.ini settings and make sure the following variables are larger than the size of the file you’re trying to upload (in this example we’ll set the values to 500 MB): upload_max_filesize = 500M post_max_size = 500M However, in my scenario this was not the solution. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)