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

How we can show the uploaded file(s) in file input ( using formbuilder ) ? #1554

Open
mansiraval1977 opened this issue Apr 24, 2024 · 1 comment

Comments

@mansiraval1977
Copy link

mansiraval1977 commented Apr 24, 2024

Description:

I have rendered the form and also used the UserData (from the FormRender), but when I edit the form data, it's visible all the input type values but not showing the file data in the preview.
Is there any way to show the uploaded files? 
Is there any way to get uploaded files in the input sections?

please help me in this case as soon as possible.

this issue is similar with "How Should I Store Image In Jquery Form Builder Because in user data we can't store file,so how i store image,file and show them" issue

Environment Details:

  • formBuilder Version: v3.19.7
  • Browser: Chrome
  • OS: Windows
<script src="https://formbuilder.online/assets/js/form-render.min.js"></script>

Expected Behavior

  1. I want to show the file input data or the uploaded file data in the preview and in the edit form.
  2. Need to handle the edit file input data (if I am not updating the images or uploading the images, then old values should not be flushed).

Actual Behavior

Currently, it's showing all the input type data without file input

Steps to Reproduce

Screenshot - (optional)

image

@muhdhatim
Copy link

muhdhatim commented May 22, 2024

you should make a custom event to detect the changes where the selected file from the file input are stored in an object. Then, send along with the userData json using js FormData(). Eg:

let loadedFile= [];//store the selected file in array 
let body = new FormData();
body.append('asssessment_form', JSON.stringify(this.formrender.userData));
          this.loadedFile.forEach((element: any, index: number) => {
            body.append(`assessment_file[${index}][file]`, element.file);
            body.append(`assessment_file[${index}][field_name]`, element.field_name);//should store field name generated by the formbuilder plugin as well

          });

Then sent formData through ajax to backend. Eg, PHP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants