4
hallo there, trying to use the uploader class, having a few probs though.
I have setup a form through php like the following
Quote:
$imagesdir = XOOPS_ROOT_PATH."/modules/../images/";
echo "<form method=post action=images.php name='upload' enctype='multipart/form-data'>\n";
echo "<input type='file' name='filename' size='50'>";
echo "<input type=\"hidden\" name=\"op\" value=\"addImage\"></input>";
echo "<input type=\"submit\" class=\"button\" value=\""._MD_ADD."\"></input>\n";
echo " <input type=\"button\" value=\""._MD_BACK."\" onclick=\"javascript:history.go(-1)\">";
echo "</center>";
echo "</form>";}
now in the addimage function i have this code Quote:
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
$error =0;
$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
$maxfilesize = 50000;
$maxfilewidth = 450;
$maxfileheight = 650;
$i=0;
$imagetitle="filename";
$filename = basename($HTTP_POST_FILES[$imagetitle]['name']);
$uploader = new XoopsMediaUploader($imagesdir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($filename)) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo '<h4>File uploaded successfully!</h4>';
echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />';
echo 'Full path: ' . $uploader->getSavedDestination();
$name=$uploader->getSavedFileName();
$sql = sprintf...
}
} else {
echo $uploader->getErrors();
}
when i click the submit button all i get is there were errors during uploading and file not found. do i pass the correct parameter ($filename) to uploads()???
is this class used to any modules where i can see an example?
anyone has any ideas of what i'm doing wrong? Thanks