8
Thanks Kaotik,
I don't know if I'm willing to give up on the xoopsuploader quite yet. It seems to be working in other parts of the site.
I think Draven has a point. It's pretty much the same conclusion I have come to...but I can't figure out why my variable is not being passed on?
Basically I am trying to create an image-upload for the Xoopspartners module. I think it is silly to have to input the src code for each images. Especially for those who don't know a squat about img src code(my client).
Plus there's a dissadvantage if your partner removes or changes their logo without you knowing it. (Which can currently be seen on Xoops's site where the Brazilian Support site logo is missing) ex.
https://xoops.org/modules/xoopspartners/Anyhow, I hope someone could give me a hand with this. Basically I have made an instance where I am trying to get the image upload to work without the other form items. Here's my code:
function imageUpload()
{
$xoopsDB =& Database::getInstance();
$myts =& MyTextSanitizer::getInstance();
xoops_cp_header();
echo ""
._MD_PARTNERADMIN."";
include XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$form = new XoopsThemeForm(_MD_ADDPARTNER, "addform", "index.php");
$op_hidden = new XoopsFormHidden("op", "uppImage");
$submit_button = new XoopsFormButton("", "submit", "Upload", "submit");
$form->addElement($formweight);
//TN removed: $form->addElement($formimage);
//TN trying to add image upload
$form -> addElement( new XoopsFormFile( 'Upload an image', 'partnerlogo', '250000' ), false );
//TN EOF
$form->addElement($op_hidden);
$form->addElement($submit_button);
$form->display();
xoops_cp_footer();
}
function uppImage()
{
$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
$maxfilesize = 50000;
$maxfilewidth = 120;
$maxfileheight = 120;
include_once(XOOPS_ROOT_PATH."/class/uploader.php");
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH."/modules/xoopspartners/images/uploads/", $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($HTTP_POST_VARS['partnerlogo'])) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo 'File uploaded successfully!
';
echo 'Saved as: ' . $uploader->getSavedFileName() . '
';
echo 'Full path: ' . $uploader->getSavedDestination();
}
} else {
echo $uploader->getErrors();
}
exit();
}
But I am getting the following error:
Errors Returned While Uploading
File not found
Notice [PHP]: Undefined variable: HTTP_POST_VARS in file c:\web\xoops\modules\xoopspartners\admin\index.php line 196