1
Hi guys, and sorry for my english,
I met the same issue, and I found a solution:
In fact, if I'm not wrong, what you need to understand is that only the variable's content you use in your XoopsFormFile function (fichier_profil for me), is used.
So don't make the FetchMedia test on the variable's name you used, but on the one use by the XOOPS class.
If my explanations do not seem clear to you, please take a look on the code below, as it worked for me.
switch($op) {
case 'do_upload':
$allowed_mimetypes = array('application/lua','image/png','image/gif','image/jpg');
$maxfilesize = 5000000;
$maxfilewidth = 5000000;
$maxfileheight = 5000000;
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH.'/modules/wowclan/profils',$allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo '<h4>Fichier uploadé avec succés!</h4>';
echo 'Enregistré sous : ' . $uploader->getSavedFileName() . '<br />';
echo 'Chemin complet: ' . $uploader->getSavedDestination();
}
} else {
echo $uploader->getErrors();
}
break;
case 'default':
default:
$description = new XoopsFormFile("Selectionner votre profil", "fichier_profil", 5000000);
$op_hidden = new XoopsFormHidden("op", "do_upload");
$button = new XoopsFormButton("", "submit", "Uploader", "submit");
$form = new XoopsThemeForm("UPLOADER", "formulaire", "upload.php", "POST", true);
$form->setExtra( "enctype='multipart/form-data'" ) ;
$form->addElement($description);
$form->addElement($op_hidden);
$form->addElement($button);
$form->display();
break;
}
I met the same issue, and I found a solution:
In fact, if I'm not wrong, what you need to understand is that only the variable's content you use in your XoopsFormFile function (fichier_profil for me), is used.
So don't make the FetchMedia test on the variable's name you used, but on the one use by the XOOPS class.
If my explanations do not seem clear to you, please take a look on the code below, as it worked for me.
switch($op) {
case 'do_upload':
$allowed_mimetypes = array('application/lua','image/png','image/gif','image/jpg');
$maxfilesize = 5000000;
$maxfilewidth = 5000000;
$maxfileheight = 5000000;
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH.'/modules/wowclan/profils',$allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo '<h4>Fichier uploadé avec succés!</h4>';
echo 'Enregistré sous : ' . $uploader->getSavedFileName() . '<br />';
echo 'Chemin complet: ' . $uploader->getSavedDestination();
}
} else {
echo $uploader->getErrors();
}
break;
case 'default':
default:
$description = new XoopsFormFile("Selectionner votre profil", "fichier_profil", 5000000);
$op_hidden = new XoopsFormHidden("op", "do_upload");
$button = new XoopsFormButton("", "submit", "Uploader", "submit");
$form = new XoopsThemeForm("UPLOADER", "formulaire", "upload.php", "POST", true);
$form->setExtra( "enctype='multipart/form-data'" ) ;
$form->addElement($description);
$form->addElement($op_hidden);
$form->addElement($button);
$form->display();
break;
}