mysqli - PHP, MySQL(i) and Dropzone -
i wondering if can tell me i'm doing wrong. goal pretty simple. using dropzone or php upload file , insert record database. able post record except 1 field showing "array" entry. i've tried changing variable names, inserting , removing quotes, etc no avail. suggestions appreciated. here 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 } $servername = "localhost"; $username = "root"; $password = "***************"; $dbname = "drop"; // create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // check connection if (!$conn) { die("connection failed: " . mysqli_connect_error()); } $sql = "insert uploads (id, file_name) values (null, 'file_name')"; if (mysqli_query($conn, $sql)) { echo "new record created successfully"; } else { echo "error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); ?>
figured out own question. answer replacing file_name $targetfile. works expected. thanks.