Open vishwas-027 opened 1 month ago
<?php
class FileUploadController { public function uploadCsvFile() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $targetDir = DIR . "/uploads/"; if (!file_exists($targetDir)) { mkdir($targetDir, 0777, true); }
$targetFile = $targetDir . basename($_FILES["file"]["name"]);
$fileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
if ($fileType != "csv") {
echo "Only CSV files are allowed.";
return;
}
if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile)) {
echo "The file " . htmlspecialchars(basename($_FILES["file"]["name"])) . " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
}
class FileBrowserController { public function getCsvFiles() { $dir = DIR . "/uploads/"; $files = [];
if (file_exists($dir)) {
$files = array_diff(scandir($dir), array('.', '..'));
}
header('Content-Type: application/json');
echo json_encode($files);
}
}
<?php
class FileUploadController { public function uploadCsvFile() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $targetDir = DIR . "/uploads/"; if (!file_exists($targetDir)) { mkdir($targetDir, 0777, true); }
$targetFile = $targetDir . basename($_FILES["file"]["name"]);
$fileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
if ($fileType != "csv") {
echo "Only CSV files are allowed.";
return;
}
if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile)) {
echo "The file " . htmlspecialchars(basename($_FILES["file"]["name"])) . " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
}
class FileBrowserController { public function getCsvFiles() { $dir = DIR . "/uploads/"; $files = [];
if (file_exists($dir)) {
$files = array_diff(scandir($dir), array('.', '..'));
}
header('Content-Type: application/json');
echo json_encode($files);
}
}
Hi
<?php
class FileUploadController { public function uploadCsvFile() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $targetDir = DIR . "/uploads/"; if (!file_exists($targetDir)) { mkdir($targetDir, 0777, true); }
$targetFile = $targetDir . basename($_FILES["file"]["name"]);
$fileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
if ($fileType != "csv") {
echo "Only CSV files are allowed.";
return;
}
if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile)) {
echo "The file " . htmlspecialchars(basename($_FILES["file"]["name"])) . " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
}
class FileBrowserController { public function getCsvFiles() { $dir = DIR . "/uploads/"; $files = [];
if (file_exists($dir)) {
$files = array_diff(scandir($dir), array('.', '..'));
}
header('Content-Type: application/json');
echo json_encode($files);
}
}``
<?php
class FileUploadController { public function uploadCsvFile() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $targetDir = DIR . "/uploads/"; if (!file_exists($targetDir)) { mkdir($targetDir, 0777, true); }
}
class FileBrowserController { public function getCsvFiles() { $dir = DIR . "/uploads/"; $files = [];
}