dropzone.js on submit php upload

hello
so i figured out how this dropzone works and i understand nothing in javascript or Ajax

i have this dropzone.js file and i found code how to make it upload on submit but i am very stupid in this and i have no idea
where whould i add?

my code looks like this
[php]




Drop files here or click to upload.


[/php]
and upload happeing in this same upload.php page
[php]<?php
include(“includes/connect.php”);
if (isset($_POST[‘upload’]))
{
$UploadName = $_FILES[‘file’][‘name’];
echo “$UploadName”;
}
?>[/php]

where i have to add that code to make it work? my question is how to get that to php code? please help

You don’t check for the button, you check if it was submitted.

if($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
{
// process request

} else {
// serve the form
}

And you want to do that at the top of the page.

it still doesnt work

this is at top of the page
if (isset($_POST[‘upload’]))
{
$UploadName = $_FILES[‘file’][‘name’];
echo “$UploadName”;
}
?>
Upload


Drop files here or click to upload.

but i haven’t added that https://github.com/enyo/dropzone/wiki/Upload-all-files-with-a-button code cuz no idea where should i do that

You link the js file to the file that the upload form is on.

i just have to link it and i dont need change anything in that file to it work?

copy the example html

maybe i can add you somewhere and we chat live? i can pay you…

At work, cannot chat live.

Add the html form code to your php file, replacing your current form. Add the javascript link to the html. The reason is, your form does not have the ID that the JS file is looking for, so nothing will be trigger it to run.

Your form is in the upload.php file, correct?

well it kinda works now when i press button it shows upload but where the files go? where i need to writte code for that?

https://www.w3schools.com/php/php_file_upload.asp

Where you are checking if the form was submitted. The above has the base that I use to process file uploads. You will likely need to modify it to suit your needs.

can i do submit from other form like

Drag drop upload here

so this is my code now

Submit all files

it all works when i press button it shows uploading etc… but nothing is happening

php at top of the page

if (isset($_POST[‘upload’]))
{
$UploadName = $_FILES[‘file’][‘name’];
echo “$UploadName”;
}
it shows nothing

If it has the id that the JavaScript is listening for.

yea i got that but it doesnt trigger that php post thing when i press button

only thing left is how to make it go to my php code after i press that button and php reads files from that dropzone

well this is my final code

//PHP

<?php include("includes/connect.php"); if(isset($_POST["upload"])) { $UploadName = $_FILES['my-dropzone']['name']; echo "$UploadName"; } ?>

// Upload

//POST

and it shows this error Notice: Undefined index: my-dropzone in C:\xampp\htdocs\upload.php on line 4

line 4:
$UploadName = $_FILES[‘my-dropzone’][‘name’];

You need to chexk what tje processing code is receiving.

[php]print_r($_FILES)[/php]

still haven’t fixed this problem

i have made that when u select or drag and drop files they show in upload box and after you press button submit they uploads
but i have no idea where they go, where should i write php part for upload?

code:

Upload:


Drop files here or click to upload.

Button click after click files uploads:


Submit

where can i write code for this upload i really have no idea how you connect php and javascript

This is how i used to work with submits

<?php if (isset($_POST['register'])) { then i get values like this $username = $_POST['username']; $email = $_POST['email']; } ?> if anyone could tell me how i can get values like this from my upload box i would appreciate that

The complete PHP tutorial in the dropzone js docs should get you going
http://www.dropzonejs.com/#server-side-implementation

Sponsor our Newsletter | Privacy Policy | Terms of Service