File "upload_chatgpt.php"
Full Path: /home/analogde/www/30_09_2024/upload_chatgpt.php
File size: 2.15 KB
MIME-type: text/x-php
Charset: utf-8
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$nom_fichier_upload = $_POST['stringData'];
/*$string = file_get_contents($nom_fichier_upload);
$linecount = 0;
$handle = fopen($nom_fichier_upload, "r");
while(!feof($handle))
{
$line = fgets($handle);
$linecount++;
}
fclose($handle);
//echo $linecount;*/
$myArray = [];
$myArray[] = $nom_fichier_upload;
//$selection_files_upload = [];
//if( file_exists($nom_fichier_upload) )
//{
// $myArray[] = "fichier existe !";
//}
//$myArray[] = $linecount;
//$myArray[] = $string;
/*
//$reception_array = [];
if ($handle = fopen($description, 'r'))
{
while (($ligne = fgets($handle)) !== false)
{
$myArray[] = $ligne;
$selection_files_upload[] = $ligne;
}
fclose($handle);
print_r($selection_files_upload);
}
*/
// Vérifier si des fichiers ont été téléchargés
if (!empty($_FILES['files']))
{
//$handle = fopen("envoi.txt", "w") or die("Unable to open file!");
//fwrite($handle, $description ."\n");
foreach ($_FILES['files']['tmp_name'] as $key => $tmpName)
{
$fileName = $_FILES['files']['name'][$key];
$fileTmp = $_FILES['files']['tmp_name'][$key];
$fileError = $_FILES['files']['error'][$key];
//fwrite($handle, $fileName ."\n");
//$myArray[] = $fileName;
//$ref = "gaz.pdf";
if (strpos($string, $filename) !== false)
{
//for($i = 0; $i < count($selection_files_upload) ; $i++)
//{
// if( $selection_files_upload[$i] == $fileName)
// {
/*if ($fileError === UPLOAD_ERR_OK)
{*/
// Déplacer le fichier téléchargé dans un répertoire souhaité
//move_uploaded_file($fileTmp, 'uploads/' . basename($fileName));
/*}*/
//}
//}
}
}
// Réponse au client
//echo "Description : $description, Fichiers téléchargés : " . count($_FILES['files']['name']);
print_r($myArray);
}
else
{
echo "Aucune donnée reçue.";
}
/*
if (in_array($string, $owned_urls))
{
echo "Match found";
return true;
}
else
{
echo "Match not found";
return false;
}
*/
?>