<p>Im my form, I also have a hidden field for the user photo:</p>

<p><code>&lt;input type="hidden" name="photo" value="{{ currentUser.photo }}"&gt;</code>.</p>

<p>I have <code>{% if currentUser.photo %}</code> instead of <code>{% if currentUser.photoUrl|length %}</code>.</p>

<p>Also, <code>&lt;img src="{{ currentUser.getPhoto.getUrl() }}"&gt;</code> instead of <code>&lt;img src="{{ currentUser.photoUrl }}"&gt;</code>. This should display the current photo.</p>

<p>EDIT:</p>

<p>File input field name should be <code>photo</code>: <code>&lt;input type="file" id="photo" name="photo"&gt;</code></p>

CC BY-SA 4.0
2018-11-30T18:30:23.483Z
Thanks Andrea, unfortunately even with adding a hidden value the form does not successfully change the photo.
JMKelley
CC BY-SA 4.0
2018-11-30T20:48:58.630Z
Oops! Forgot the file input field. See updated answer.
Andrea DeMers
CC BY-SA 4.0
2018-11-30T17:35:52.673Z
2018-11-30T20:28:09.377Z
2018-11-30T20:28:09.377Z
Andrea DeMers
<p>I have this form, there's no errors getting thrown and the User photo field is not updating via this form.</p>

<pre><code>      &lt;form method="post" accept-charset="UTF-8" enctype="multipart/form-data"&gt;
        {{ csrfInput() }}
        &lt;input type="hidden" name="action" value="users/save-user"&gt;
        &lt;input type="hidden" name="redirect" value="users/{{ currentUser.username }}"&gt;
        &lt;input type="hidden" name="userId" value="{{ currentUser.id }}"&gt;

        &lt;div class="form-group"&gt;
          {% if currentUser.photoUrl|length %}
              &lt;img src="{{ currentUser.photoUrl }}" class="img-fluid mb-2 border" /&gt;
          {% else %}
            &lt;img src="http://placehold.it/1024x468/f5f5f5/ccc.png" class="img-fluid mb-2" alt="{{ entry.title }}" /&gt;
          {% endif %}
          &lt;label&gt;Profile Picture&lt;/label&gt;
          &lt;input type="file" name="fields[photo]" class="form-control-file upload"&gt;
        &lt;/div&gt;

        &lt;input type="submit" value="Save Profile"&gt;

      &lt;/form&gt;
</code></pre>

<p>I'm unsure why it's not working, as it's fairly identical to some questions on SO.</p>

<templating>
Updating User Photo from Front-End
# Updating User Photo from Front-End

(Asked by: username_0 on 2018-11-30)

I have this form, there's no errors getting thrown and the User photo field is not updating via this form.
      
        {{ csrfInput() }}
        
        
        

        
          {% if currentUser.photoUrl|length %}
              
          {% else %}
            
          {% endif %}
          Profile Picture
          
        

        

      

I'm unsure why it's not working, as it's fairly identical to some questions on SO.

**Tags:** templating

---

## 1 answers

### Answer by username_1 on 2018-11-30. Score: 2 | Accepted answer

Im my form, I also have a hidden field for the user photo:

.

I have `{% if currentUser.photo %}` instead of `{% if currentUser.photoUrl|length %}`.

Also, `![]({{ currentUser.getPhoto.getUrl() }})` instead of `![]({{ currentUser.photoUrl }})`. This should display the current photo.

EDIT:

File input field name should be `photo`:

> **Comments:**
> **username_0**: Thanks Andrea, unfortunately even with adding a hidden value the form does not successfully change the photo.  
> **username_1**: Oops! Forgot the file input field. See updated answer.  

---

