dropzone.js on submit php upload


#1

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


#2

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.


#3

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


#4

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


#5

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


#6

copy the example html


#7

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


#8

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?


#9

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?


#10

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.


#11

can i do submit from other form like

Drag drop upload here

#12

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


#13

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


#14

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


#15

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


#16

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’];


#17

You need to chexk what tje processing code is receiving.

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


#18

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


#19

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

#20

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