8
Made a test on 2.4.2 and had no problems. I used your code to create two programs in the XOOPS root. Only slight changes where made. Only one remark on your code: inconsistant closing tag for the input statements. tstupload.html
<html>
<head>
head>
<body>
<form method='post' action='upload_image.php' enctype='multipart/form-data'>
<input type="file" id="file" name="file" size="50" maxlength="60" />
<input id="xoops_upload_file[]" type="hidden" value="file" name="xoops_upload_file[]"/><br><br>
<input type="hidden" id="lid" name="lid" size="50" maxlength="60" value="123" />
<input type="submit" class="button" name="submit" id="submit" value="Add pic" />
form>
body>html>
upload_image.php
include_once './mainfile.php';
global $xoopsDB, $_POST, $myts, $eh;
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
include_once XOOPS_ROOT_PATH.'/class/module.errorhandler.php';
$lid = $_POST["lid"];
$destination_path = XOOPS_ROOT_PATH."/uploads/";
$allowed_mimetypes = array('image/gif', 'image/jpeg','image/png');
$maxfilesize = 4194304;
$maxfilewidth = 800;
$maxfileheight = 800;
$uploader = new XoopsMediaUploader($destination_path, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
$uploader->setPrefix("shot");
$x=0;
if ($uploader->fetchMedia($_POST['xoops_upload_file'][$x]))
{
if (!$uploader->upload())
{
$result = $uploader->getErrors();
echo $result;
} else //update db
{
$logourl = $uploader->getSavedFileName();
// $xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("myreviews_images")." (lid, src) VALUES ($lid, $logourl)") or $eh->show("0013");
// redirect_header("index.php",1,_MD_DBUPDATED);
echo 'ok'.$lid. $logourl;
}
}
else {
print_r($_POST);
}
?>
Remark: Puts the file in uploads as eg shot4b2ebf7b64874.gif Shows OK with id = 123 and filename generated in stead of the actual database operation eg ok123shot4b2ebf7b64874.gif .