We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46220
    • 66 Posts
    Ok, let me fully break down what I have right now. I followed the instructions and made the changes mentioned above. Also created a snippet called avatarUpload with the code mentioned above.

    My update profile looks like this:
    [[!UpdateProfile? &useExtended=`1`
    &postHooks=`postHook.DiscussUpdateProfile`,`redirect_profile_update`
    &preHooks=`user_profile_image`,`user_profile_image`]]
    
    [[!DiscussUpdateProfileLoader]]
    
    <div class="prof-update">
    
     <div class="update-profile">
      <div class="updprof-error">
       [[+error.message]]
      </div>
    
      [[+login.update_success:if=`[[+login.update_success]]`:is=`1`:then=`[[%login.profile_updated? &namespace=`login` &topic=`updateprofile`]]`]]
    
      <form class="form" enctype="multipart/form-data" action="[[~[[*id]]]]" method="post">
      <input type="hidden" name="nospam:blank" value="" />
    
      <p>
       <label for="fullname">[[!%login.fullname? &namespace=`login` &topic=`updateprofile`]]
       <span class="error">[[+error.fullname]]</span>
       </label>
       <br />
       <input type="text" name="fullname" id="fullname" value="[[+fullname]]" />
      </p>
    
      <p>
       <label for="email">[[!%login.email]]
       <span class="error">[[+error.email]]</span>
       </label>
       <br />
       <input type="text" name="email:required:email" id="email" value="[[+email]]" />
      </p>
    
      <p>
       <label for="gender">Gender
       <span class="error">[[+error.gender]]</span>
       </label>
       <br />
       <select name="gender">
       <option value="m" [[+gender::is=`m`:then=`selected`]]>Male</option>
       <option value="f" [[+gender:is=`f`:then=`selected`]]>Female</option>
       </select>
      </p>
    
      <p>
       <label for="country">[[!%login.country]]
       <span class="error">[[+error.country]]</span>
       </label>
       <br />
       <select name="country">[[!FormItCountryOptions? &selected=`[[!+fi.country]]`&prioritized=`US,GB,DE,RU,JP,FR,NL,CA,AU` &prioritizedGroupText=`Most registered` &allGroupText=`All countries`]]</select>
      </p>
    
      <p>
       <label for="city">[[!%login.city]]
       <span class="error">[[+error.city]]</span>
       </label>
       <br />
       <input type="text" name="city" id="city" value="[[+city]]" />
      </p>
    
      <p>
       <label for="website">[[!%login.website]]
       <span class="error">[[+error.website]]</span>
       </label>
       <br />
       <input type="text" name="website" id="website" value="[[+website]]" />
      </p>
    
      <p>
       <label for="signature">Signature 
       <span class="error">[[!+up.error.signature:stripTags=`p,b,strong,i,a,ul,li`]]</span>
       </label>
       <br />
       <textarea name="signature:allowTags" id="signature">[[!+up.signature]] cols="30" rows="10"</textarea>
      </p>
    
      <p>
       <label for="use_display_name">Use Display Name in Forums 
       <span class="error">[[!+up.error.use_display_name]]</span>
       </label>
       <br />
       <input type="hidden" name="use_display_name" id="use_display_name_hidden" value="0" /><input type="checkbox" name="use_display_name" id="use_display_name" value="1" [[!+up.use_display_name:FormItIsChecked=`1`]] />
      </p>
    
      <p>
       <label for="display_name">Display Name 
       <span class="error">[[!+up.error.display_name]]</span>
       </label>
       <br />
       <input type="text" name="display_name" id="display_name" value="[[+up.display_name]]" />
      </p>
    
      <p>
       <label for="show_online">Show Online Status 
       <span class="error">[[!+up.error.show_online]]</span>
       </label>
       <br />
       <input type="hidden" name="show_online" id="show_online_hidden" value="0" /><input type="checkbox" name="show_online" id="show_online" value="1" [[!+up.show_online:FormItIsChecked=`1`]] />
      </p>
    
      <p>
       <label for="show_email">Show Email in Forums 
       <span class="error">[[!+up.error.show_email]]</span>
       </label>
       <br />
       <input type="hidden" name="show_email" id="show_email_hidden" value="0" /><input type="checkbox" name="show_email" id="show_email" value="1" [[!+up.show_email:FormItIsChecked=`1`]] />
      </p>
    
      <p>
       <div class="label"><img src="[[+Profile_Photos:phpthumbof=`w=120&h=120&zc=1&fltr[]=ric|20|20`]]" /></div> <span class="error">[[+fi.error.Profile_Photos]]</span>
       <div class="input"><input id="Profile_Photos" name="Profile_Photos" type="file" value="[[+fi.Profile_Photos]]" maxlength="100000" /></div>
      </p>
    
      <br class="clear" />
       <div class="form-buttons">
       <br />
    
       <p>
        <input type="submit" name="login-updprof-btn" value="Update Profile" />
        <span class="return-to-members-home"> return to <a href="[[~21]]">Members Home Page</a></span>
       </p>
    
      </div>
      </form>
     </div>
    </div>

    In line 111 and 112 is the avatar upload bit. I've also tried by replacing "Profile_Photos" with "avatarUpload". When I click the button, I can choose a file, and when "Update Profile" is clicked, I get no error message, but also don't get a saved message which I used to get.
      • 46886
      • 1,154 Posts
      Ok here is what I got, this works for sure.

      My best suggestion right now, outside this code below, is lets make sure you got the right packages installed. I have phpThumbOf installed, and that's it, no other thumb stuff.

      Here is my update profile, the upload pic is at the end:

      [[!UpdateProfile? 
      &postHooks=`postHook.DiscussUpdateProfile` 
      &preHooks=`avatarUpload`
      &useExtended=`1`
      &excludeExtended=`email:required:email,display_name,show_email,show_online,Profile_Photos,use_display_name,signature,signature:allowTags,login-updprof-btn`
      &validate=`nospam:blank,`']] 
      [[!DiscussUpdateProfileLoader]]
      
      <h1>Personal Information</h1>
       
      <div class="update-profile">
          <div class="updprof-error">[[+error.message]]</div>
      [[+login.update_success:is=`1`:then=`[[%login.profile_updated? &namespace=`login` &topic=`updateprofile`]]`]]
          
          <form class="form" enctype="multipart/form-data" action="[[~[[*id]]]]" method="post">
              <input type="hidden" name="nospam" value="" />
              <!--Current Location-->
              <label for="current_location">Current Location: 
                  <span class="error">[[+reg.error.current_location]]</span>
              </label>
              <input type="text" name="current_location" id="current_location" value="[[+current_location]]" />
              <br class="clear" />
              <!--Display name-->
      <li style="border-bottom:1px dashed #7e7e7e;"><label for="display_name">Display Name <span class="error">[[!+up.error.display_name]]</span></label>
      <input type="text" name="display_name" id="display_name" value="[[+up.display_name]]" />
       <!--Use displayname-->
      <label for="use_display_name"> Use Display Name in Forums<span class="error">[[!+up.error.use_display_name]]</span></label>
      <input type="hidden" name="use_display_name" id="use_display_name_hidden" value="0" />
      <input type="checkbox" name="use_display_name" id="use_display_name" value="1" [[!+up.use_display_name:FormItIsChecked=`1`]] /></li>
              <br class="clear" />
              <!--Signature-->
      <li style="border-bottom:1px dashed #7e7e7e;"><label for="signature">Signature<span class="error">[[!+up.error.signature:stripTags=`p,b,strong,i,a,ul,li`]]</span></label>
      <textarea name="signature:allowTags" id="signature">[[!+up.signature]]</textarea></li>
        
              <br class="clear" />
              <br class="clear" />
        <!--Show email-->
      <li style="border-bottom:1px dashed #7e7e7e;"><label for="show_email">Show Email in Forums <span class="error">[[!+up.error.show_email]]</span></label>
      <input type="hidden" name="show_email" id="show_email_hidden" value="0" />
      <input type="checkbox" name="show_email" id="show_email" value="1" [[!+up.show_email:FormItIsChecked=`1`]] />
        
        <!--Show online status-->
        <label for="show_online">Show Online Status <span class="error">[[!+up.error.show_online]]</span> </label>
      <input type="hidden" name="show_online" id="show_online_hidden" value="0" />
      <input type="checkbox" name="show_online" id="show_online" value="1" [[!+up.show_online:FormItIsChecked=`1`]] /></li>
              <br class="clear" />    
      <li style="border-bottom:1px dashed #7e7e7e;"><div class="label"><img src="[[+Profile_Photos:phpthumbof=`w=80&h=80&zc=1`]]" /></div>Choose Your Avatar <span class="error">[[+fi.error.Profile_Photos]]</span>
              <div class="input"><input id="Profile_Photos" name="Profile_Photos" type="file" value="[[+fi.Profile_Photos]]" maxlength="100000" /></div>
              </div>
                <p class="note">Filesize must not exceed 2mb and 250X250 pixels. Preview is disabled; after saving your picture go to your profile and refresh the page to see your avatar.</p></li>
      </ul>
              <br class="clear" />
              <div class="form-buttons">
                  <input type="submit" name="login-updprof-btn" value="Save" />
              </div>
          </form>
      </div>
        • 46886
        • 1,154 Posts
        Here is the important stuff, should have just given you this:

        <div class="label"><img src="[[+Profile_Photos:phpthumbof=`w=80&h=80&zc=1`]]" /></div>Choose Your Avatar <span class="error">[[+fi.error.Profile_Photos]]</span>
                <div class="input"><input id="Profile_Photos" name="Profile_Photos" type="file" value="[[+fi.Profile_Photos]]" maxlength="100000" /></div>
                </div>
          • 46886
          • 1,154 Posts
          and to confirm, the folder created is assets/userfiles.

          one negative, it *seems* to make a folder for every user with a default image. So all my testing users have folders there.
            • 46886
            • 1,154 Posts
            So I would say first, copy my code and make sure it works, you have some extra stuff in there. Then if it can work, the next step is do what you want.

            I see you want 120 size, its a good idea, I don't know if it will "fit" in the space provided in the post view though, but I would like to have bigger too. Espeically on the profile page.

            Also you are doing something else as well, not sure what though.
              • 46220
              • 66 Posts
              Thanks again so far mate! Now I am at least 1 step further, it actually uploaded a file into my assets/userfiles but it is still not showing. So will be digging into that now. Back with my findings later again.
                • 46886
                • 1,154 Posts
                Ok let me look at how it does that on mine. Make sure the code in the post view is what I have above, and same for the profile page, those are the two places it should be, but the default code needs some changes.

                I will make sure about the process and whether anything else is involved.
                  • 46220
                  • 66 Posts
                  Sorted!! laugh

                  In the description [[+discuss.user.username]]/avatar.gif is used, but for my admin account, I have a username that is different from my display name. The file is saved as administrator/avatar.gif instead of "username"/avatar.gif. So it is a minor issue, and it is working, just need to sort it to avoid anyone else to have the same problem as me.
                    • 46886
                    • 1,154 Posts
                    Sweet! So much progress recently!!