upload file to server

Questions related to customising nuBuilder Forte with Javascript or PHP.

Re: upload file to server

Postby johan » Tue Nov 19, 2019 5:23 pm

Kev1n

This is my result
Attachments
Selectie_175.png
Selectie_175.png (5.2 KiB) Viewed 1002 times
johan
 
Posts: 306
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: upload file to server

Postby kev1n » Tue Nov 19, 2019 5:38 pm

Add

Code: Select all
debugger;
in this code (input_type_file.htm) and open the developer console (F12).

debugger.png
debugger.png (12.65 KiB) Viewed 1001 times


Then upload the file and press F10 when the debugger stops to jump to the next row and to investigate the variables.

Video:

https://streamable.com/x1y19


result.error should be empty if the upload was successful.
kev1n
 
Posts: 728
Joined: Mon Oct 15, 2018 2:13 am

Re: upload file to server

Postby johan » Tue Nov 19, 2019 11:23 pm

Kev1n

I get this error
Code: Select all
<this>: {…}

arguments: Arguments

data: "{\"status\":\"error\",\"error\":\"ERROR_MOVING_FILE\"}"

err: undefined

result: undefined


data: "{\"status\":\"error\",\"error\":\"ERROR_MOVING_FILE\"}"

err: "The file cannot be moved to the destination directory."

result: {…}


I don't understand why it's not possible to move the file to my server.
johan
 
Posts: 306
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: upload file to server

Postby kev1n » Tue Nov 19, 2019 11:32 pm

What value does $uploaddir (Upload directory) have in your upload.php?
kev1n
 
Posts: 728
Joined: Mon Oct 15, 2018 2:13 am

Re: upload file to server

Postby kev1n » Tue Nov 19, 2019 11:38 pm

You could also try setting the variable to "document root" / nuBuilder root dir (and create there a documents folder)

$uploaddir = $_SERVER['DOCUMENT_ROOT']."/documents/";
kev1n
 
Posts: 728
Joined: Mon Oct 15, 2018 2:13 am

Re: upload file to server

Postby johan » Wed Nov 20, 2019 4:18 pm

Kev1n
changed $uploaddir = './documents/' to $uploaddir = './documents' and now the upload works.
But my file is saved in folder upload not in folder documents.

When I try to reopen the file it points to the wrong url (in documents)

Johan
johan
 
Posts: 306
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: upload file to server

Postby kev1n » Wed Nov 20, 2019 4:46 pm

Use the latest upload.php file

https://github.com/smalos/nubuilder-cod ... upload.php

and try setting the upload directory to

Code: Select all
$uploaddir = $_SERVER['DOCUMENT_ROOT']."/libs/upload/documents/";
kev1n
 
Posts: 728
Joined: Mon Oct 15, 2018 2:13 am

Re: upload file to server

Postby johan » Thu Nov 21, 2019 6:44 pm

Kev1n

With the new script it works fine. Thanks for your help.

Just 1 suggestion?

Is it possible to remove the file from the server when deleted in Nubuilder?

Johan
johan
 
Posts: 306
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: upload file to server

Postby kev1n » Thu Nov 21, 2019 7:22 pm

How do you want to delete the File in nuBuilder? On a button click?
kev1n
 
Posts: 728
Joined: Mon Oct 15, 2018 2:13 am

Re: upload file to server

Postby johan » Thu Nov 21, 2019 10:07 pm

Kev1n
Just when I delete a subrow containing a file.
Than the row is deleted in de sql table.

Johan
johan
 
Posts: 306
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

PreviousNext

Return to Custom Code



cron