upload multiple files - Forum

Forum Navigation
You need to log in to create posts and topics.

upload multiple files

Hello, I have found this script on the web, but when I use it with VNW I have an error and I don't understand why ? Can someone help me ?

https://www.geeksforgeeks.org/how-to-select-and-upload-multiple-files-with-html-and-php-using-http-post/

Array ( [files] => Array ( [name] => A330.jpg [type] => image/jpeg [tmp_name] => C:\Users\PhAla\AppData\Local\Temp\phpCF8.tmp [error] => 0 [size] => 7864 ) ) A330.jpg
Warning: array_filter() expects parameter 1 to be array, string given in E:\Philippe\Documents\VisualNeoWeb\Projets\Diapo-Web\file_upload.php on line 17
No files selected.

line 17 = if(!empty(array_filter($_FILES['files']['name']))) {...

This is a total guess because I don't know much about PHP, but is your form set to have the multipart encoding?

Uploaded files:
  • You need to login to have access to uploads.

Of course @Susan I copied the entire HTML and PHP into VNW, and I tested $_FILES which contains the data wells

@phil78 I am trying to learn more about PHP, so if you have a small project file with the problem, I am happy to be a second set of eyes.

Hi @susan Here is the files. the target folder name you have to create is : uploads

Uploaded files:
  • You need to login to have access to uploads.

@phil78 Thanks for the files to play with. I have discovered why the multiple upload is not working, but I don't know enough to suggest how to fix it.

The first image is the code produced by VisualNEO Web as shown with the View Page Source of the browser, and there the name of the input includes the [] to indicate an array of values which is important!

But in the second image compare the input name in the Code Inspector of the browser developer tools and the square brackets are missing, and so only the last file of the selection is sent to your PHP code because it is the array needed for multiple files.

Why does this happen? I have no idea, but maybe there is some AngularJS interaction going on that is modifying the HTML input tags?

Uploaded files:
  • You need to login to have access to uploads.
luishp has reacted to this post.
luishp

@susan @phil78 if you need to use brackets in your HTML code just use this special css class (Properties Panel > Advanced) in the Container:

ng-non-bindable

This will tell AngularJS not to process brackets as if they were part of a variable.
The change should solve the problem.

Please take a look here:
https://visualneo.com/forum/topic/displaying-variable-names-in-a-container

Regards.

susan has reacted to this post.
susan

Thank you @lusihp I can confirm that solves the problem!

luishp has reacted to this post.
luishp

thank you @susan and @luishp , I confirm also, you are a guru !

One other question, If I try to do the same thing with a VNW form and a VNW file input, files[] is not filled and it seems not to call file_upload.php ?

Uploaded files:
  • You need to login to have access to uploads.

@phil78 multiple file uploads are not curretly supported by the default Form Object. Sorry.

@luishp Can it evolve in a next version?

@phil78 I will try but not easy due to damn brackets! LOL

@luishp @phil78 @susan

Hi guys

Take a look at the demo of the plugin that we are working on
with optional image preview (customizable preview size).
It will include php file and demo ready to compile.

Tested locally using "neoPHP Server" and my server online.

More demo plugins for  VisualNeoWeb: https://acplugins.com/vnweb

Suggestions are welcome.

luishp, Vadim and 3 other users have reacted to this post.
luishpVadimsmartmediaroccocoglianoPhil78

@asleycruz wow! you are doing quite interesting plugins.
I can't wait :)

@luishp @phil78 @susan & coders

You can already take a look at the new images of
acImageUploader plugin at: https://acplugins.com/vnweb

Plugins for VisualNEOWeb are now available to purchase via PayPal.
Any problem let me know. Best regards :)

luishp and fkapnist have reacted to this post.
luishpfkapnist

if you remember I use a container for my form and submit. It works well, now but after loading the report is displayed on a new page file_upload.php, and I need to go back manually.

Is it possible to get the report and stay in my app ?

@phil78 please check this link:
https://stackoverflow.com/questions/6877759/submit-a-form-in-the-background

Regards.

Phil78 and susan have reacted to this post.
Phil78susan