Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

upload file to server

Questions related to customising nuBuilder Forte with JavaScript or PHP.
johan
Posts: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: upload file to server

Unread post by johan »

Kev1n

This is my result
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: upload file to server

Unread post by kev1n »

Add

Code: Select all

debugger;
in this code (input_type_file.htm) and open the developer console (F12).
debugger.png
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.
You do not have the required permissions to view the files attached to this post.
johan
Posts: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: upload file to server

Unread post by johan »

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.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: upload file to server

Unread post by kev1n »

What value does $uploaddir (Upload directory) have in your upload.php?
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: upload file to server

Unread post by kev1n »

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

$uploaddir = $_SERVER['DOCUMENT_ROOT']."/documents/";
johan
Posts: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: upload file to server

Unread post by johan »

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
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: upload file to server

Unread post by kev1n »

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/";
johan
Posts: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: upload file to server

Unread post by johan »

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
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: upload file to server

Unread post by kev1n »

How do you want to delete the File in nuBuilder? On a button click?
johan
Posts: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: upload file to server

Unread post by johan »

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

Johan
Post Reply