Primo commit: trasferimento del progetto PPEasy

This commit is contained in:
2024-09-18 10:30:50 +02:00
commit eb475f257e
4233 changed files with 1043848 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
if(isset($_POST) == true){
//generate unique file name
$fileName = time().'_'.basename($_FILES["file"]["name"]);
//file upload path
$targetDir = "uploaddocuments/";
$targetFilePath = $targetDir . $fileName;
//allow certain file formats
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
$allowTypes = array('jpg','png','PNG','jpeg','gif','pdf');
if(in_array($fileType, $allowTypes)){
//upload file to server
if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){
//insert file data into the database if needed
//........
$response['status'] = 'ok';
$response['filename'] = $fileName;
}else{
$response['status'] = 'err';
}
}else{
$response['status'] = 'type_err';
}
//render response data in JSON format
echo json_encode($response);
}