1

I would like to make an image upload field so new members are required to upload a picture. I'm new to Craft (I've been a Drupal Front End developer). Other custom fields are working perfectly, and I've added enctype="multipart/form-data" to my form tag. This is how my input field looks like now, but I get a CException error.

    <h3><label for="userPhoto">Upload Foto</label></h3>                
    <input type="file" name="userPhoto"
    {%- if account is defined %} value="{{ account.userPhoto }}"{% endif %}>
    {% if account is defined %}
    {{ errorList(account.getErrors('userPhoto')) }}
    {% endif %}

I've been searching for a while now but can't seem to find an answer on it. So I hope someone can help me :-). Thanks a lot!

  • 1
    What's the error you're getting? – Brad Bell Mar 25 '16 at 16:35
  • It seems to work sometimes, I have successfully uploaded 2 pictures, but sometimes it doesn't do anything, and I get this error: Craft\EntryModel and its behaviors do not have a method or closure named "userPhoto". – Jan Mar 29 '16 at 7:10
  • So I've been testing over and over again, and I've found the problem; since I've been testing it all quickly and forgot that I need a 6 digit password. So: it does work, but I get an "ugly" error message, it should only say that the password isn't long enough instead of this CException error 'cause that's not user friendly, and this is a registration form so I could do with a nice error. I'll get there eventually :-) – Jan Mar 29 '16 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.