user1628778
user1628778

Reputation: 1

Can't upload images in wordpress

I am trying to add images to my post, but I keep getting the following messege: "An error occurred in the upload. Please try again later."

Note that I can see the images in the media library.

I am working on localhost.

using wordpress 3.8.1.

Upvotes: 0

Views: 2300

Answers (4)

user1628778
user1628778

Reputation: 1

There was a problem with code in my template (something related to unclosed tags), so tracing back my code solved the problem.

Upvotes: 0

Ravi Patel
Ravi Patel

Reputation: 5231

If you have issues in finding:

require_once(ABSPATH . 'wp-settings.php');” 
then find  define('WP_DEBUG', false);and add the below given code before it:

define(‘CONCATENATE_SCRIPTS’, false );

enter image description here

Upvotes: 0

Mou
Mou

Reputation: 491

Well, after digging into the issue, it seems like the process only fails if a post_id value is set and the user doesn’t have rights to edit the post with that id.

Go to wp-includes/media.php

Look for *wp_enqueue_media* function afterwards move to this block

$post = null;
    if ( isset( $args['post'] ) ) {
        $post = get_post( $args['post'] );
        $settings['post'] = array(
            'id' => $post->ID,
            'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
        );

and change it to

$post = null;
    if ( isset( $args['post'] ) ) {
        $post = get_post( $args['post'] );

        if (is_admin()) {
            $settings['post'] = array(
                'id' => $post->ID,
                'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
            );
        }

Upvotes: 0

Mou
Mou

Reputation: 491

it can be due to the Plugin conflict.To check whether it is actually the case,disable all of your plugin by navigating to WordPress Admin Dashboard > Plugins > Select All Plugins > Bulk Action > Disable > Go

Upvotes: 1

Related Questions