} } // traitement fichiers //print_r($_FILES); foreach ($_FILES as $formFileId => $file) { if ($file['size'] > 0) { $fileName = $file['name']; $tmpName = $file['tmp_name']; $fileSize = $file['size']; $fileType = $file['type']; $idFichier = substr($formFileId, 7); $req = "INSERT INTO fichierDonne (idRenduDonne, nom, type, idFichier) " . "VALUES (?, ?, ?, ?)"; //echo "<!-- $req -->"; $idFichierDonne = DB::insert_autoinc($req, array($idRenduDonne, $fileName, $fileType, $idFichier)); fileIdToPath($idFichierDonne, $fspath, $fsname); createFilePath($fspath); // déplace à son emplacement final dans le data store move_uploaded_file($tmpName, $fspath . $fsname); /* $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); #$content = addslashes($content); No longer needed with PDO fclose($fp); * */ // Ajout à l'e-mail $mail->AddAttachment($fspath . $fsname, $fileName); if (true) { echo "<p>Fichier {$fileName} téléchargé</p>"; } } else { echo "<p>Fichier " . $file["name"] . " sauté car de taille zéro.</p>";
/* This file is part of Envoi. Envoi is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Envoi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Envoi. If not, see <http://www.gnu.org/licenses/>. (c) Christophe Jacquet, 2009-2011. */ require "tools.php"; $res = DB::request("SELECT idFichierDonne, contenu FROM fichierDonne"); while ($row = $res->fetch()) { fileIdToPath($row->idFichierDonne, $path, $name); createFilePath($path); echo "{$path} {$name}: "; if (file_put_contents($path . $name, $row->contenu) === FALSE) { echo "FAILED!\n"; break; } else { echo "OK\n"; } }