Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
file upload to server
file upload to server
Hi, we are trying to make file uploads work as suggested on the forum here:
https://forums.nubuilder.cloud/viewtopic. ... d&start=10
But, we would like to allow multiple files to be added to the same record, so we created a table that will link recordid and uploaded file (file uploads get a unique name).
The problem we are having is that the name of the file is not available in the after-save handlers.
Where should we insert the code to write the record to the files table we created?
Johan
https://forums.nubuilder.cloud/viewtopic. ... d&start=10
But, we would like to allow multiple files to be added to the same record, so we created a table that will link recordid and uploaded file (file uploads get a unique name).
The problem we are having is that the name of the file is not available in the after-save handlers.
Where should we insert the code to write the record to the files table we created?
Johan
-
- nuBuilder Team
- Posts: 4305
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 446 times
- Contact:
Re: file upload to server
In Javascript, use an array to store the file names:
In PHP, use json_decode() to decode the JSON string an you want to loop through the array, use a foreach loop.
Code: Select all
// Create an array
var files = new Array;
// Push the file names to the array
files.push(first_file);
files.push(second_file);
// ....
// Convert the array to a JSON string and set a hash cookie:
var j = JSON.stringify(files);
nuSetProperty('myfiles',j);
Code: Select all
$f = json_decode("#myfiles#")
Re: file upload to server
Kevin
Thanks for your reply.
Where should we inject that java code in the linked solution? I assume it needs to go somewhere in the code that calls process_file.php?
Johan
Thanks for your reply.
Where should we inject that java code in the linked solution? I assume it needs to go somewhere in the code that calls process_file.php?
Johan
-
- nuBuilder Team
- Posts: 4305
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 446 times
- Contact:
Re: file upload to server
Within the ajax success callback (added lines flagged with *ADD* )johan wrote:Where should we inject that java code in the linked solution? I assume it needs to go somewhere in the code that calls process_file.php?
You do not have the required permissions to view the files attached to this post.
Re: file upload to server
Kevin
I changed the HTML code to that in the image, but now the upload fails, the error in the console is:
ReferenceError: f is not defined
What did I miss?
I changed the HTML code to that in the image, but now the upload fails, the error in the console is:
ReferenceError: f is not defined
What did I miss?
-
- nuBuilder Team
- Posts: 4305
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 446 times
- Contact:
Re: file upload to server
If you click on this "VM"-link, you'll see the line the causes the error.
You do not have the required permissions to view the files attached to this post.
Re: file upload to server
Kevin
My error points to
My error points to
I don't see any ffunction nuLoginRequest(u, p){
$.ajax({
async : true,
dataType : "json",
url : "nuapi.php",
method : "POST",
data : {nuSTATE :
{call_type : 'login',
username : arguments.length 0 ? $('#nuusername').val() : u,
password : arguments.length 0 ? $('#nupassword').val() : p,
login_form_id : nuLoginF,
login_record_id : nuLoginR}
},
dataType : "json",
-
- nuBuilder Team
- Posts: 4305
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 446 times
- Contact:
Re: file upload to server
I don't know what your code looks like and where you added it. Without that information it's next to impossible to know what causes this error.
Re: file upload to server
Kevin
We find our error in the object (Html) part.
Now we can try the rest.
Thanks
Johan
We find our error in the object (Html) part.
Now we can try the rest.
Thanks
Johan
Re: file upload to server
Kevin
"We want to write data to another table using the after save handler where we have the recordid available. How would we do that? Specificly, looking at how to use the SQL connection Nubuilder already has
"We want to write data to another table using the after save handler where we have the recordid available. How would we do that? Specificly, looking at how to use the SQL connection Nubuilder already has