Estiliza pagina de upload externo - responsiva (novo47)
This commit is contained in:
1 parent
05cd7b9c79
commit
deb0eabf25
9 files changed
+525
-24
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$upload_dir = "uploads/";
|
||||
$processed_dir = "processed/";
|
||||
|
||||
// Criar diretórios se não existirem
|
||||
if (!file_exists($upload_dir)) mkdir($upload_dir, 0777, true);
|
||||
if (!file_exists($processed_dir)) mkdir($processed_dir, 0777, true);
|
||||
|
||||
if ($_FILES["document"]["error"] == 0) {
|
||||
$temp = $_FILES["document"]["tmp_name"];
|
||||
$name = basename($_FILES["document"]["name"]);
|
||||
$doc_type = $_POST["doc_type"];
|
||||
$client_id = $_POST["client_id"];
|
||||
|
||||
// Criar diretório específico do cliente
|
||||
$client_dir = $processed_dir . $client_id . "/";
|
||||
if (!file_exists($client_dir)) mkdir($client_dir, 0777, true);
|
||||
|
||||
// Salvar arquivo original
|
||||
$original_path = $upload_dir . $name;
|
||||
move_uploaded_file($temp, $original_path);
|
||||
|
||||
// Chamar script Python
|
||||
$output = array();
|
||||
$command = "python document_detector.py " . escapeshellarg($original_path) . " " .
|
||||
escapeshellarg($doc_type) . " " . escapeshellarg($client_dir);
|
||||
exec($command, $output);
|
||||
|
||||
// Registrar no banco de dados
|
||||
$processed_file = $client_dir . $doc_type . "_" . $name;
|
||||
$sql = "INSERT INTO documentos (client_id, tipo, arquivo, data_upload)
|
||||
VALUES (?, ?, ?, NOW())";
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("iss", $client_id, $doc_type, $processed_file);
|
||||
$stmt->execute();
|
||||
|
||||
header("Location: index.php?page=doc_list&client_id=" . $client_id);
|
||||
} else {
|
||||
header("Location: index.php?page=doc_upload&error=1");
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user