Hi everyone,
My english is poor, sorry
I’ve got a php file with php and html code, work perfect !
When i cutted it into 2 parts for my modx-template (php-code for the snipped and html for the document) it doesn’t work anymore !
The snippet i called [[azerty]]
<?php
if(isset($_FILES[’photo’]))
// params
unset($erreur);
$extensions_ok = array(’png’, ’gif’, ’jpg’, ’jpeg’, ’doc’ );
$taille_max = 10000000;
$dest_dossier = ’frecu/’;
// vérifications
if( !in_array( substr(strrchr($_FILES[’photo’][’name’], ’.’), 1), $extensions_ok ) )
{
$erreur = ’Veuillez sélectionner un fichier de type png, gif ou jpg !’;
}
elseif( file_exists($_FILES[’photo’][’tmp_name’])
and filesize($_FILES[’photo’][’tmp_name’]) > $taille_max)
{
$erreur = ’Votre fichier doit faire moins de 500Ko !’;
}
// copie du fichier
if(!isset($erreur))
{
$dest_fichier = basename($_FILES[’photo’][’name’]);
// formatage nom fichier
// enlever les accents
$dest_fichier = strtr($dest_fichier, ’ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ’, ’AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiii ioooooouuuuyy’);
// remplacer les caracteres autres que lettres, chiffres et point par _
$dest_fichier = preg_replace(’/([^.a-z0-1]+)/i’, ’_’, $dest_fichier);
// copie du fichier
move_uploaded_file($_FILES[’photo’][’tmp_name’], $dest_dossier . $dest_fichier);
}
}
if(isset($erreur)){
echo ’<p>’, $erreur ,’</p>’;
?>
The second part for my .html file
<!-- Formulaire -->
<!-- Attention, ne de ne pas oublier le enctype="multipart/form-data" -->
<form method="POST" enctype="multipart/form-data">
<!-- Limiter la taille des fichiers à 500Ko -->
<input type="hidden" name="MAX_FILE_SIZE" value="50000000" />
<fieldset>
<legend>Envoi de fichiers</legend>
<!-- champs d’envoi de fichier, de type file -->
<p><label for="photo">Photo :</label><input type="file" name="photo" /></p>
<p><label for="photo_2">Photo 2 :</label><input type="file" name="photo_2" /></p>
<!-- bouton d’envoi -->
<p><input type="submit" name="envoi" value="Envoyer les fichiers" /></p>
</legend>
</fieldset>
</form>
When I copy/paste the 2 parts into 1 part and called it test.php, it is working ! but into 2 parts, doesn’t work.
Second prob : when i call my snippet, i’ve got this on my screen "my modx page" (title) ? WHY ?
Can you help me ?? pleaaaasee
Thanks you so much !!!