I'm working with a channel form entries and the EE built-in file upload button.

Below is my code for adding an image to your profile entry.

The first time a user selects browse and uploads an image from their computer this code works fine. When the user goes back to edit their profile picture, sometimes the image will change, and sometimes it will not even load the image to the directory. Is there a way to change this behavior.

I'm working with EE v5.4.1. I'm relatively new working with Expression Engine. Any advice, or tips would be helpful, thanks in advance.

{!--photo selection using native EE file type--}
<label for="avatar">Choose a logo picture:</label>  
<input type="file" name="logo" style="display:inline-block;" id="logo"/>
<input type="hidden" name="logo_directory" value="6" />
<img src="{logo}"style="max-height:100px; max-width:100px;"/>
<input type="hidden" name="logo_hidden_file" value="{logo}{file_name}{/logo}" />
  • Any chance you can post a minimum example template to reproduce this?
    – Tom Jaeger
    May 29 at 0:15
  • Thanks for responding Tom. I looked into my problem more and I found out that when I upload a file to Expression Engine, the first time it will load the image to the server, but changing the photo will not post onto the server. Also these posts are returning a 302 found redirect status, and posting as a query string. Have you even encountered that when dealing with file uploads on EE?
    – Amy
    May 31 at 12:57
  • 1
    This sounds more like an issue with your server / site setup than this specific function. Do other file uploads (i.e. direct via the CP to the Files area) work OK? Jun 2 at 12:27
  • @JCOGSDesign You are right, it is dealing with the server. As of right now the issue still remains, but isn't top priority. But I still want to know how to fix this issue. File uploads via the CP work just fine. What would cause the server to treat this file upload as a 302 redirect? Any helpful tips? Thanks
    – Amy
    Jun 3 at 3:23

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.