简体   繁体   中英

Dropzone.js with mysql

I want insert in Mysql the files of Dropzone.js form.

How can make this?

HTML CODE

<form action="upload.php" class="dropzone"></form>

PHP UPLOAD CODE

<?php
$ds          = DIRECTORY_SEPARATOR;  //1

$storeFolder = 'uploads';   //2

if (!empty($_FILES)) {

    $tempFile = $_FILES['file']['tmp_name'];          //3             

    $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;  //4

    $targetFile =  $targetPath. $_FILES['file']['name'];  //5

    move_uploaded_file($tempFile,$targetFile); //6

}
?>

I use this below

<?php   
require 'functions/myconnectionfile.php';

$ds = DIRECTORY_SEPARATOR;
$storeFolder = "uploads/";

if (!empty($_FILES)) {
    $fileupload = basename( $_FILES['file']['name']);
    $fileType = $_FILES['file']['type'];
    $fileSize = $_FILES['file']['size'];

    $tempFile = $_FILES['file']['tmp_name'];
    $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
    $targetFile =  $targetPath. $fileupload;
    move_uploaded_file($tempFile,$targetFile);
    $uploadsql = "INSERT INTO uploads (Filename, description, Type, Size)
                  VALUES ('$fileupload', 'test uploads', '$fileType', '$fileSize')";
    mysql_query($uploadsql);
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM