I think I get the whole concept nuBuilder uses for an Input:file object. It looks like when there is a change to an Input:file object the event fires the nuChangeFile() function in nuform.js, which in turn JSON-ifies the file data and saves it in a hidden textarea. If my understanding is correct, then would this be the place that I would want to add some code to save the file to the server? And to do that, would I be correct in assuming that I would need to ajax the file to some PHP code that would in turn save the file to the server?
What I want to do is bypass the saving of the JSON data and just save the file to the server, and just save the path to the saved file. What I don't yet understand is where in the nuBuilder code does the Input:file object get placed on the form? That is the spot that I would have to make additional changes in order to read the file back in. My goal would be much better if I could figure a way to do what I want without changing any nuBuilder code. Any ideas?
TIA
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Another Input:file object question
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Another Input:file object question
Tony,
I was faced with a similar task when I needed to upload a file to my server and then send it by email. At the end of the day, I decided not to use nuBuilder's Input FileUpload Object but went for another solution because It took about 4 minutes to upload/send a 100KB file.
It's based on this code https://gist.github.com/matteomattei/e2 ... 73b2da2921 (with slight modifications to meet my own needs)
I was faced with a similar task when I needed to upload a file to my server and then send it by email. At the end of the day, I decided not to use nuBuilder's Input FileUpload Object but went for another solution because It took about 4 minutes to upload/send a 100KB file.
It's based on this code https://gist.github.com/matteomattei/e2 ... 73b2da2921 (with slight modifications to meet my own needs)
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Re: Another Input:file object question
Thanks bunches toms. I got the file upload to work without too much fuss, and it is rather speedy, too. No more "Request Data Too Large" errors like I used to get trying to save the file to the database. Now I just need to figure out how to retrieve the file when the Edit form displays again. Unfortunately, my brain has shut down for the moment. 

TonyD
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Another Input:file object question
The ajax success function returns the file names (In my case just 1 file name since I disallow multiple files)
This saves the filename to a nuBuilder field:
Then create a html object that displays a link to your file on the server
<a href="path_to_server/#myfilename#" download="path_to_server/#myfilename#">Download</a>
This saves the filename to a nuBuilder field:
Code: Select all
success: function (res) {
....
if(result.res === true){
...
$('#myfilename').val(result.data[0]).change();
...
}
<a href="path_to_server/#myfilename#" download="path_to_server/#myfilename#">Download</a>
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm