File upload not working

Hi, Today I created a File Upload form and connected it to a Server Connect API. But the API is not working properly. I did go through the tutorial on this topic but the interface explained there is well out of date. The form I created successfully accesses the User’s folders and successfully chooses a file. The filepath is successfully passed as a POST variable to the API. The API I have so far is …

image

Please ignore the tst messages, they are just my way of debugging.

The important statements are ‘If Folder Exists’ , ‘Create Folder’ and ‘File Upload’

The API stops dead as soon as any of these are encountered. If I disable them
flow continues. But of course I do need them.

I suspect there must be something fundamental I am doing wrong here, because this method is very differnt to Teodor’s tutorial he published a year or 2 ago (and some of the steps he tutored no longer exist in wappler).

So the question is, how do FIle Uploads get done these days?

Nothing has actually changed in the way file upload works. The steps are the same - you select your POST var and upload folder then the file is uploaded.
What have you selected in the upload step? Please post some screenshots.

Also when you are saying:

Have you checked for errors returned by the server action?

Hi Teodor

I will follow through on your suggestion, in the meantime, where is the fileupload spec. The value of the $_POST.Filename is correct in the API, I have checked that. And I have a Try/Catch around the whole lot, but there is no Response error message. I will switch on debug and have a look in Chrome shortly.

image

Enable these two options:

Screenshot 2021-09-27 at 11.25.28

And check if there are any errors in the dev tools as explained in the article above.

Hi Teodore
I followed thru on your suggestions. But first I noticed that one of the tickboxes on the upload file properties is to automatically create the path, therefore I got rid of the folder mgt that you saw before in my API.

The first problem that was revealed was my pathname that I was loading to was invalid. That error went away when I put a ‘/’ as the first character. Putting a ‘/’ as the last character seemed to be accepted as well. So now the API runs through without faltering.

image

In Chrome I could see

image

and the status in the header is 200, which is good I believe.
2 questions…

  1. the c:\fakepath (highlighted in yellow ) does get displayed in wappler but this path does not exist on my c drive, is it a wappler generated path?

2.The last line, ‘upload: ’ seems as though there should be filename there, I do not really know, but it feels incorrect.

But the upshot is that the file did not upload, at least I cannot find it anywhere in my website. Where would you expect the file to be saved to?

The path must be selected through the folder icon so you should not be adding any / before the path. This will be added when you select the upload folder. So please select the upload folder using the path picker.
Then test again.

Hi Teodore

THe filepath is now

image

Chrome reports…

But again, the file has not appeared om the website, nor in the c: drive folders that mirror the website.

So have you checked your server and the location you selected for upload?
What is your server model? Where is the upload folder located in your site?

I have, I have created folder uploaded_files in all of

  1. the root folder
  2. the root folder/public_html
  3. the root folder/public_html/marama <-- thought I would see the uploaded files here, but no show so far.

uploaded_files has not self created anywhere else on the web site.

Not sure what are you doing exactly …
Your upload folder should be located in the site root folder, not in the server root. So when you pick it, make sure it is in the folder your site files are located in.
Just use the folder picker and create your upload folder in the site root.

On the server it should be in the … https://mysite.com/my_uploads

Ok, when I clicked the folder icon in the file upload properties, it drops me into my c drive, the highlighted folder is the one that I chose.

image

On the web site the structure is slightly different in that the root of teh website is directly under Public_html instead of being under the marama subfolder . I am not sure how that happened, but it hasn’t hurt so far.

image .

I am probably asking the obvious here, but is that the problem?

Which folder is selected locally for your site root?

I just saw another line in your previous reply, the folder that you expect does exist

Which folder is selected locally for your site root?

c:\public_html\marama

Are you sure the upload is properly set up then?
Can you please add a setvalue step in your server action and use as an expression the post variable you are using for your file upload step: $_POST.Filename, enable output for it and and run the upload. Does the setvalue return anything?

Yes, already done that, and it does return the correct value.
The yellow hightlight is a setvalue from the API

I mean - check the server action response in the dev tools, where the setvalue step is outputting its value.

Ok , here it is, is this what you mean? Should there be a filename where teh blue arrow is pointing?

Your POST var is then not setup properly. That is not what is supposed to be displayed in the server action response.
Are you sure your POST variable is defined as type: File?

No, i missed that point, it was just text.

But I changed it to File but I do not teh heirarchy I can see in your example.

Just realised, I am linking from a text box, so let me try to correct that.