1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
//Start of specific code
//Include file submition form
// Check if there is no errors
if (isset($_FILES['Template_XML']) AND $_FILES['Template_XML']['error'] == 0)
{
// Check file size <= 10 Mo
if ($_FILES['Template_XML']['size'] <= 10000000)
{
// Check file extension as XML
$infofile = pathinfo($_FILES['Template_XML']['name']);
$extension_upload = $infofile['extension'];
$extensions_autorized = array('xml');
if (in_array($extension_upload, $extensions_autorized))
{
// Transfert of file on server
$path = '../www/wp-content/themes/softing-child/';
$filename = basename($_FILES['Template_XML']['name']);
$fichier = move_uploaded_file($_FILES['Template_XML']['tmp_name'],$path . $filename);
echo "Well done ! Your Word XML Template has been successfully transmitted for automation !".'<br/>';
}
}
}
// Un bloc ou je fait des modification dans le fichier provenant du formulaire
// puis je force le téléchargement
//Force download of updated XML file
if (file_exists($path . $filename))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($path . $filename));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path . $filename));
ob_clean();
flush();
readfile($path . $filename);
exit;
}
?> |
Partager