I give some details :
This is a form with or without attachments.
Without the function setTimeout(), fileguidlist is null.
- <?php
require_once "../phpuploader/include_phpuploader.php" ;
/*** After the POST ***/
if(isset($_POST['grade'])) {
// Enregistrer les données du formulaire et générer $num
require_once "../demandeur/enregistrer.php" ;
// Les fonctions
require_once "../include/fonctions.inc.php" ;
// Déposer les fichiers uploadés - Caution : without setTimeout() : $fileguidlist is null !!!
$fileguidlist = @$_POST["myuploader"];
if($fileguidlist) {
$num = $num_dossier."_" ;
$guidlist = explode("/",$fileguidlist);
$uploader = new PhpUploader();
foreach($guidlist as $fileguid)
{
$mvcfile = $uploader->GetUploadedFile($fileguid);
if($mvcfile)
{
$targetfilepath = "../savefiles/".$num.$mvcfile->FileName;
$targetfilepath = SupprimerAccents($targetfilepath) ;
$mvcfile->MoveTo($targetfilepath);
}
}
}
// Rediriger après enregistrement
echo "<script>window.location='ticket_psi.php?num=".$num_dossier."'</script>";
exit() ;
} - ?>
- <HTML>
- ...
- <script type="text/javascript">
function doStart(){
if(VerifierFormulaire() != false) {
var uploadobj = document.getElementById('myuploader');
if (uploadobj.getqueuecount() > 0) {
setTimeout(function() {
uploadobj.startupload();
}, 10);
return false;
}
else {
var confirmer = confirm("Envoyer sans fichiers ?");
if(confirmer == false) {
return false;
}
}
}
else {
return false;
}
} - </script>
- ....
- <form onSubmit="return doStart();" method="post">
- .....
- <td><select name="grade" value="">
- <option value="0">Sélectionner un grade ...</option>
- <?php affiche_grade(); ?>
- </select>
- </td>
- ......
- <td><input type="reset" value="Annuler" name="annuler" />
- <input type="submit" value="Envoyer" />
- </td>
- ......
- <td class="firsttd">Les pièces jointes</td>
- <td><?php
- $uploader=new PhpUploader();
- $uploader->MaxSizeKB=10240;
- $uploader->Name="myuploader";
- $uploader->InsertText="Sélectionner les fichiers";
- $uploader->AllowedFileExtensions="*.pdf,*.ods,*.odt";
- $uploader->MultipleFilesUpload=true;
- $uploader->ManualStartUpload=true;
- $uploader->Render();
- ?>
- <ol id="filelist">
- </ol>
- </td>
- </tr>
- .....
- </form>
- ....
- </HTML>
Regards,