i want to pass on an int (The project id) to make a query in the php file that uploads the file, everything works, but i have to pass on the int which is $project[0][0]; towards the file_upload_parse.php. someone please help me out
this is currently the code (HTML/ PHP):
<?php
if ($project[0][5] == true) {
echo "<div class=\"ui cards\">
<div class=\"card\" style=\"width: 100vw;\">
<div class=\"content\">
<div class=\"header\">
<div class=\"meta\">
<span class=\"right floated time\">" . $project[0][2] . "</span>
<a style=\"font-size: 0.7em\" class=\"category\"> <i class=\"Reply icon\"></i>" . $lang['VIEW_PREVIOUS'] . "</a>
</div>
<h1><i class=\"File Pdf Outline icon\" style=\"font-size: 2em; padding:14px; margin-right: 20px;\"></i>" . $project[0][1] . " " . $lang['PRESENTATION'] . " </h1>
</div>
<br>
</div>
<form style='margin-bottom:0px;' id='upload_form' method='POST' enctype='multipart/form-data'>
<div class=\"extra content\">
<div class=\"ui two buttons\">
<a href='uploads/".$upload[0][1]."' download='' class=\"ui green button\"><i class=\"download icon\"></i>" . $lang['DOWNLOAD'] . "</a>
<label for=\"presentation\" class=\"ui icon button\">
<i class=\"file icon\"></i>
" . $lang['UPLOAD_NEW_PRESENTATION'] . "</label>
<input onchange=\"selectFile()\" type='file' name='presentation' style='display:none;' id=\"presentation\" class=\"ui basic red button\"></div>
</div>
</div>
</form>
</div>
</div>";
}
?>
</div>
this is currently the code (THE JS IS LOCATED ON THE BOTTOM OF THE PAGE) (JS/PHP):
function selectFile() {
var file = _("presentation").files[0];
uploadFile(file);
$('.ui.modal')
.modal('show')
;
}
function uploadFile(file) {
var file = _("presentation").files[0];
var formdata = new FormData();
formdata.append("presentation", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "templates/upload/file_upload_parse.php");
ajax.send(formdata);
}
function progressHandler(event) {
var percent = (event.loaded / event.total) * 100;
console.log(percent);
// _("progressBar").value = percent = Math.round(percent);
// _("status").innerHTML = Math.round(percent)+ " uploaded";
}
function completeHandler(event) {
$('.ui.modal')
.modal('hide')
;
console.log("closed");
}
function errorHandler(event) {
_("status").innerHTML = "failed";
}
function abortHandler(event) {
_("progressBar").value = 0;
}
this is currently the code (HTML/ PHP):
<?php
include "../../models/login.php";
$con = new User();
if (isset($_FILES['presentation'])){
$filename = $_FILES['presentation']['name'];
$fileTmpLoc = $_FILES['presentation']['tmp_name'];
$fileType = $_FILES['presentation']['type'];
$fileSize = $_FILES['presentation']['size'];
$fileErrorMsg = $_FILES['presentation']['error'];
$file_ext = explode('.',$filename);
$file_ext = strtolower(end($file_ext));
$allowed = array('txt' , 'pdf','png','jpg');
if (in_array($file_ext, $allowed)){
if ($fileSize <= 2000000000){
$file_name_new = uniqid('', true) . '.' . $file_ext;
if (move_uploaded_file($fileTmpLoc, "../../uploads/$file_name_new")){
$con->executeQuery("INSERT INTO `uploads`(`project_id`, `location`, `file_kind`) VALUES (".$_GET['projectid'].",'".$file_name_new."','presentation')");
$con->executeQuery("UPDATE `GGD`.`projects` SET `presentation` = '1' WHERE `projects`.`id` =".$_GET['projectid']);
}
}
}
}