Skip to content

CI4: Convert File Upload Functionality #3452

Closed

Description

@objecttothis

Issue / Bug / Question / New Feature

CI4 does not do image uploads the same way as CI3. We need to convert part of the save_info() and all of the _handle_logo_upload() function in app/Controllers/Config.php

https://codeigniter.com/userguide3/libraries/file_uploading.html?highlight=upload

  • Company logo upload in Configuration > Information
  • item image upload in views/items/form.php starting at line 378 and getRemoveLogo()/postSave() in the items controller

Activity

  1. linked a pull request that will close this issueUpgrade CI to 4.1.3 (Old) #3271on Apr 1, 2022
  2. bradl822 commented on Apr 1, 2022

    @bradl822

    Not sure if this is the forum for this but I for one would love the ability to have 2 logo's. One for receipts and one for the ospos login page.
    I use a thermal printer and to ensure the logo prints well I have a really scaled back image for the thermal printer however it detracts from the overall look when logging in.

  3. objecttothis commented on Apr 4, 2022

    @objecttothis
    MemberAuthor

    Not sure if this is the forum for this but I for one would love the ability to have 2 logo's. One for receipts and one for the ospos login page. I use a thermal printer and to ensure the logo prints well I have a really scaled back image for the thermal printer however it detracts from the overall look when logging in.

    Hi @bradl822. You'll need to create a new issue and fill out the details completely. If someone wants to pick up the feature request, they can do so.

  4. removed their assignment
    on Nov 1, 2022
  5. ebentil commented on Nov 20, 2022

    @ebentil
    Collaborator

    @objecttothis is it me or this has already been ported to CI4?

  6. objecttothis commented on Nov 20, 2022

    @objecttothis
    MemberAuthor

    I started it, but I'm not sure I got it 100% correct. We just ported the thumbnail creation, but this is the file upload. Right now we can't test it because there are runtime errors.

  7. ebentil commented on Nov 23, 2022

    @ebentil
    Collaborator

    I worked on the thumbnail part. The file upload part looks CI4 for me. On which branch can i find what you have done?

  8. objecttothis commented on Nov 23, 2022

    @objecttothis
    MemberAuthor

    Same branch. I'd started the work, which is why it looks CI4. I don't know that it's all correct though. If it looks good, let's leave it until the application is running and we can runtime test/debug it.

  9. linked a pull request that will close this issueFeature: CodeIgniter 4 upgrade #3592on Dec 10, 2022
  10. added this to the 3.4.0 milestone on Dec 10, 2022
  11. added
    CodeIgniter4
    on Dec 12, 2023
  12. self-assigned this
    on Feb 12, 2024
  13. objecttothis commented on Feb 20, 2024

    @objecttothis
    MemberAuthor

    @jekkos I've fixed the company logo upload and I'm working on getting it properly removing the file when the user clicks remove image in Configuration > Information. There are a few questions that remain outstanding regarding the behavior of those functions. I'm not sure what the 3.3.9 behavior is but I think we have more options in CI4.
    1- When uploading a new company_logo it goes into /public/uploads/ but do we rename the file and overwrite what is currently there?
    2- If we don't rename and overwrite, do we delete old images? Not doing this could potentially clutter up the /public/uploads/ folder.
    3- When a user clicks "Remove Image" do we leave nothing in there or do we restore the default ospos logo? The latter would require that we maintain that file with a different name (say "default_company_logo.jpg") and the value of company_logo becomes that value when the user clicks remove instead of being assigned ''.

  14. objecttothis commented on Feb 20, 2024

    @objecttothis
    MemberAuthor

    I'm looking at the code in the master and it appears that the current behavior is to upload the file name as is given by the user and when removing the logo to not remove the file itself but instead to just remove the entry in the database. I suppose we can just keep current behavior and make any other changes to the behavior in another PR. One thing we do need to do is use guessExtension() rather than just writing the extension as is given by the user. This is considered best practice for security.

  15. objecttothis commented on Feb 20, 2024

    @objecttothis
    MemberAuthor

    Company logo upload/change/remove now functions with the same functionality as 3.3.9. Next will be getting the image upload in the item edit views to work properly.

  16. odiea commented on Feb 21, 2024

    @odiea
    Collaborator

    Works great. thanks

  17. objecttothis commented on Feb 26, 2024

    @objecttothis
    MemberAuthor

    Item image upload is working again. Note: Fixing the problems required a migration script change. Make sure to run 20220127000000_convert_to_ci4.php before testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CodeIgniter4enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions