• Resolved dougjoseph

    (@dougjoseph)


    I’m on a multi-site network. I uploaded the plugin to the mu-plugins folder, and moved the avatars.php file to the root of the mu-plugins folder.

    I created a folder for avatars, and assigned it (CHMOD) 755 permissions.

    I activated the upload feature in the plugin, and told the plugin the path of the avatar folder.

    Then I logged out and back in as a regular user, and uploaded an avatar.

    I know the file got uploaded, because the file is now there on the server (visible through an FTP program).

    Yet, in WP an error message was shown: “Upload error: File upload failed.”

    The avatar does not show in WP.

    I know the file did get uploaded successfully, because not only can I see it with FTP, but also I manually browsed to its location and it shows in a browser just fine.

    Also, the plugin did store the path to the uploaded file in that user’s record: When I view the admin page (at wp-admin/ms-admin.php?page=add_local_avatar&userspage=2) the path there shows just what it should for that user’s avatar.

    I then moved the “avatars” folder to the web server root (public_html folder) and retried an upload. The error message still showed. However, the avatar displays this time.

    Some users panic when they see an error message, and some would get caught in a circle of trying again. I’m likely to remove this plugin unless someone knows how I can get it working smoothly.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter dougjoseph

    (@dougjoseph)

    OK, the title should say “not functional.” Why does the site not let me edit this? :-/

    Thread Starter dougjoseph

    (@dougjoseph)

    The problem seems to be in line 839 of the “avatars.php” file in the plugin.

    // Copy uploaded file.
    					if(!move_uploaded_file($_FILES['avatar_file']['tmp_name'], $root . $path . $file)) $error = __('File upload failed.', 'avatars');
    					else chmod($root . $path . $file, 0644);

    I know the file is getting uploaded. The original (larger) file that gets uploaded shows on the server, and the smaller version that gets created for an avatar shows on the server.

    So, why is the plugin code throwing an error that says the file upload failed?

    Thread Starter dougjoseph

    (@dougjoseph)

    I am using this hack as a fix to work around what seems to have been an ineffective or faulty error-check process.

    // Copy uploaded file.
    						// this was the original line 839: 	if(!move_uploaded_file($_FILES['avatar_file']['tmp_name'], $root . $path . $file)) $error = __('File upload failed.', 'avatars');
     						// The 2 lines below replaced that original.
    					$move_w_check = move_uploaded_file($_FILES['avatar_file']['tmp_name'], $root . $path . $file);
    					if(!file_exists($root . $path . $file)) $error = __('File upload failed. Final stage result: $move_w_check', 'avatars');
    					else chmod($root . $path . $file, 0644);

    Everything works fine now with this change. Unless I can find a problem, or unless someone points out why this hack is not a good idea, I will be moving forward with this.

    Hi, I have the same problem (file upload failed) and making the changes you suggested I get this other error: (File upload failed. Final stage result: $ move_w_check). Can you help?

    Thread Starter dougjoseph

    (@dougjoseph)

    In the error you posted, you show a space between the $ and the variable name. There should be no space. Please copy and paste the code in order to be sure no extraneous spaces or typos are occuring. If you do that, the error message should be more meaningful.

    I’m getting the same issue as ciarlystreet when pasting in the fix 3 posts up (double-checked for a space between $ and move_w_check). I’m using version 10.4 so the code line is actually later than 839 when I’m pasting in. Not sure how to fix this…

    Apparently version 9.2 addressed: “Fix for local avatar upload to cope with the ever changing WP!” but nothing’s working for me.

    Alright, finally figured this out! What I did is completely revert to the original code by redownloading the plugin. Next you:

    1. Hop in to the Network Admin area and network activate the plugin
    2. Now go to Settings >> Avatars
    3. Look for User Uploads and check the box*
    4. I then had to check the sub-box “use legacy method”
    5. Done! Works!

    Hope that helps anyone else.

    *Note just using it straight up gave issues, hence using the legacy method.

    Jason you are a genius!

    I also recommend the avatar sidebar widget from the same author which allows you to upload avatars on any page including bbpress.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Add Local Avatar] Upload Local Avatar feature not funtional’ is closed to new replies.