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 an specific url/address
-
- Posts: 21
- Joined: Mon Apr 16, 2018 9:12 am
file upload to an specific url/address
It seems input:File uploads files directly into database. Is there any solution for uploading files directly into an specific folder of url/address?
I have many large files and can't rely to database to hold them.
Thanks in advance.
I have many large files and can't rely to database to hold them.
Thanks in advance.
Re: file upload to an specific url/address
omid020,
That's not what nuBuilder is for so you'll need to use a third party product like Dropbox.
Steven
That's not what nuBuilder is for so you'll need to use a third party product like Dropbox.
Steven
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: file upload to an specific url/address
Hi,
This can be done with ajax and php and works just fine.
I'm using this code with slight modifications: https://gist.github.com/matteomattei/e2 ... 73b2da2921
Create a object of type HTML and add the code from index.html. process_files.php has to be saved on your server.
Let me know if you need more details/instructions.
This can be done with ajax and php and works just fine.
I'm using this code with slight modifications: https://gist.github.com/matteomattei/e2 ... 73b2da2921
Create a object of type HTML and add the code from index.html. process_files.php has to be saved on your server.
Let me know if you need more details/instructions.
-
- Posts: 21
- Joined: Mon Apr 16, 2018 9:12 am
Re: file upload to an specific url/address
Hi,
Thanks for your advise. I created html object and moved process_files.php to nuBuilder main root folder, also I created uploads folder inside nuBuilder main root folder but it seems uploading operation failed; After choosing PDF file "Uploading" message loads (nothing more) and after saving form no file adds to upload folder.
Also I need to have a column (in browsing mode and within same table form) to contain a hyperlink to download the uploaded file. Could you please guide to have it?
Thanks in advance.
Thanks for your advise. I created html object and moved process_files.php to nuBuilder main root folder, also I created uploads folder inside nuBuilder main root folder but it seems uploading operation failed; After choosing PDF file "Uploading" message loads (nothing more) and after saving form no file adds to upload folder.
Also I need to have a column (in browsing mode and within same table form) to contain a hyperlink to download the uploaded file. Could you please guide to have it?
Thanks in advance.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: file upload to an specific url/address
Check the console output if you see any errors. In my case, I had to change the paths to process_files.php to /html/nuBuilder4/process_files.php (it's probably different for you)
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:
CODE: SELECT ALL
Then you can add the full path location to the filename and display it.
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:
CODE: SELECT ALL
Code: Select all
success: function (res) {
....
if(result.res === true){
...
$('#myfilename').val(result.data[0]).change();
...
}
-
- Posts: 21
- Joined: Mon Apr 16, 2018 9:12 am
Re: file upload to an specific url/address
I changed path of php file to /public_html/nuBuilder4/process_files.php or public_html/nuBuilder4/process_files.php but both didn't work.
Also console returns nothing. (please see the attachment)
Also console returns nothing. (please see the attachment)
You do not have the required permissions to view the files attached to this post.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: file upload to an specific url/address
Did you add the path to both occurrences of process_files.php?
1st occurence:
2nd occurence:
You can also add and error handler to give you more details why the upload fails.
1st occurence:
Code: Select all
$.ajax({
url: "/process_files.php",
Code: Select all
<form method="post" enctype="multipart/form-data" action="/process_files.php">
Code: Select all
$.ajax({
// ...
success: function (res) {
// ....
},
error: function(jqXHR, textStatus, errorThrown) {
alert('An error occurred... Look at the console (F12 or Ctrl+Shift+I, Console tab) for more information!');
console.log('jqXHR:');
console.log(jqXHR);
console.log('textStatus:');
console.log(textStatus);
console.log('errorThrown:');
console.log(errorThrown);
}
});
-
- Posts: 21
- Joined: Mon Apr 16, 2018 9:12 am
Re: file upload to an specific url/address
Yes I had edited path for both items.toms wrote:Did you add the path to both occurrences of process_files.php?
1st occurence:Code: Select all
$.ajax({ url: "/process_files.php",
2nd occurence:Code: Select all
<form method="post" enctype="multipart/form-data" action="/process_files.php">
I added above code into html code but still no errors apperars!toms wrote: You can also add and error handler to give you more details why the upload fails.
Code: Select all
$.ajax({ // ... success: function (res) { // .... }, error: function(jqXHR, textStatus, errorThrown) { alert('An error occurred... Look at the console (F12 or Ctrl+Shift+I, Console tab) for more information!'); console.log('jqXHR:'); console.log(jqXHR); console.log('textStatus:'); console.log(textStatus); console.log('errorThrown:'); console.log(errorThrown); } });
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: file upload to an specific url/address
Sorry, I have no idea why it's not working for you. In any case, you can also test the upload independently of nuBuilder.
Debugging Javascript might help you track down the issue as well:
https://developer.mozilla.org/en-US/doc ... JavaScript
Debugging Javascript might help you track down the issue as well:
https://developer.mozilla.org/en-US/doc ... JavaScript
-
- Posts: 21
- Joined: Mon Apr 16, 2018 9:12 am
Re: file upload to an specific url/address
Finally worked! Just removed /public_html from the path and it works like a charm!
which type of field should I add to table of database to have a link (for example a link with "download" phrase) of file for every corresponding input via your mentioned code?
which type of field should I add to table of database to have a link (for example a link with "download" phrase) of file for every corresponding input via your mentioned code?
Code: Select all
success: function (res) {
....
if(result.res === true){
...
$('#myfilename').val(result.data[0]).change();
...
}