Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI4: Convert File Upload Functionality #3452

Closed
2 tasks done
objecttothis opened this issue Apr 1, 2022 · 11 comments
Closed
2 tasks done

CI4: Convert File Upload Functionality #3452

objecttothis opened this issue Apr 1, 2022 · 11 comments
Assignees
Labels
CodeIgniter4 Issue relates to the conversion to CodeIgniter 4 enhancement
Milestone

Comments

@objecttothis
Copy link
Member

objecttothis commented Apr 1, 2022

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
@bradl822
Copy link

bradl822 commented Apr 1, 2022

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.

@objecttothis
Copy link
Member Author

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.

@objecttothis objecttothis removed their assignment Nov 1, 2022
@ebentil
Copy link
Collaborator

ebentil commented Nov 20, 2022

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

@objecttothis
Copy link
Member Author

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.

@ebentil
Copy link
Collaborator

ebentil commented Nov 23, 2022

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

@objecttothis
Copy link
Member Author

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.

@objecttothis objecttothis removed a link to a pull request Dec 10, 2022
@objecttothis objecttothis linked a pull request Dec 10, 2022 that will close this issue
34 tasks
@objecttothis objecttothis added this to the 3.4.0 milestone Dec 10, 2022
@jekkos jekkos mentioned this issue Nov 6, 2023
12 tasks
@objecttothis objecttothis added the CodeIgniter4 Issue relates to the conversion to CodeIgniter 4 label Dec 12, 2023
@objecttothis objecttothis self-assigned this Feb 12, 2024
@objecttothis
Copy link
Member Author

@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 ''.

@objecttothis
Copy link
Member Author

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.

@objecttothis
Copy link
Member Author

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.

@odiea
Copy link
Collaborator

odiea commented Feb 21, 2024

Works great. thanks

@objecttothis
Copy link
Member Author

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
Labels
CodeIgniter4 Issue relates to the conversion to CodeIgniter 4 enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants