File "envoi_multiples06.php"
Full Path: /home/analogde/www/Prog/File explorer/envoi_multiples06.php
File size: 4.4 KB
MIME-type: text/plain
Charset: utf-8
<?php
// Count total files
$countfiles = count($_FILES['files']['name']);
// Upload Location
$upload_location = "Doc_uploads/";
$upload_location = "http://analog-design.net/Administratif/CAF/";
//$upload_location = "/home/analogde/www/Administratif/CAF/";
//$upload_location = "/home/analogde/www/Administratif/CAF/";
$upload_location = "/home/analogde/www/" .$_COOKIE["cookie_upload"] ."/";
//// <?php echo fm_enc(FM_PATH)
// To store uploaded files path
$files_arr = array();
$uploaded_files_str = '';
// Loop all files
for($index = 0;$index < $countfiles;$index++)
{
if(isset($_FILES['files']['name'][$index]) && $_FILES['files']['name'][$index] != '')
{
// File name
$filename = $_FILES['files']['name'][$index];
// Get extension
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
// Valid image extension
$valid_ext = array("png","jpeg","jpg");
// Check extension
if(in_array($ext, $valid_ext))
{
// File path
$path = $upload_location.$filename;
// le fichier existe ?
//if (file_exists($my_folder . $_FILES['file']['name']))
if (file_exists($path))
{
$pos = strrpos($filename,'.');
$ext = substr($filename,$pos);
$file_basename = substr($filename, 0, strripos($filename, '.'));
$datetime = date("Y-m-d H:i:s");
$path = $upload_location .$file_basename ."_changed_" .$ext;
$path = $upload_location .$file_basename ."_" .$datetime ."_" .$ext;
//$path = $upload_location.$filename."_changed";
}
// Upload file
if(move_uploaded_file($_FILES['files']['tmp_name'][$index], $path))
{
$infos = filemtime($path);
$text = "Last modified " . date("l, dS F, Y, h:ia", $infos) . "\n";
$handle = fopen("data.txt", "w");
fwrite($handle, $text);
fclose($handle);
$filename = $_FILES['files']['name'][$index];
$filesize = $_FILES['files']['size'][$index];
$filetype = $_FILES['files']['type'][$index];
$val = $val + " *** " .$_FILES['files']['full_path'][$index];
///aaa($filename, $filesize, $filetype);
// basename($_FILES["file"]["name"]
//filemtime($_FILES['fileToUpload']["tmp_name"])
// filemtime($_FILES['files']['name'])
$files_arr[] = $path;
//$files_arr[] = $path + " Succés ";
}
/*else
{
$files_arr[] = $path + " Erreur ";
}*/
}
}
}
//
echo json_encode($files_arr);
die;
function aaa($filename, $filesize, $filetype)
{
$db_host = "analogdepat.mysql.db";
$db_user = "analogdepat";
$db_pass = "Un92pac007";
$db_name = "analogdepat";
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
/*if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}*/
// Insert the file information into the database
$sql = "INSERT INTO files (filename, filesize, filetype) VALUES ('$filename', '$filesize', '$filetype')";
$conn->query($sql);
$conn->close();
}
/*
$isValidFile = true;
// Validate if file already exists
if (file_exists($fileName)) {
echo "<span>File already exists.</span>";
$isValidFile = false;
}
*/
?>