Ok I have tried and failed, is there an article on using vB's upload function to write to the database?
This is what I'm using but would rather use vB's upload function.
PHP Code:
${'userfile'}= $vbulletin->input->clean_gpc('f','userfile',TYPE_FILE);
$path = '/home/******/public_html/*******/admincp';
$filename = str_replace("'","",$vbulletin->GPC['userfile']['name']);
$filesize = ($vbulletin->GPC['userfile']['size']/1024);
$filetype = $vbulletin->GPC['userfile']['type'];
$filetname = $vbulletin->GPC['userfile']['tmp_name'];
$fileerro = $vbulletin->GPC['userfile']['error'];
$fileext = trim(strtolower(strrchr($filename, '.')));
$tmpname = tempnam('/tmp/', $filetname);
if(move_uploaded_file($filetname, $path.$tmpname)){
$filetname = $path.$tmpname.$fileext;
}
$fp = fopen($tmpname, 'r');
if (empty($filesize)){}
else{$content = fread($filetname, filesize($filename));}
$content = addslashes($content);
fclose($fp);
unlink($tmpname);
If there is an easier way then please do tell. Right now I had it actually create a temp file in the /tmp/ directory but its file size was 0 and now it won't even write temp files to that directory so I have no clue what is going on. All necessary php functions are enabled as I have checked the php info output.
Yes I borrowed this from another mod but its only temporary until I get it working then I plan to change variables to fit my mod.
Also I have thought about just uploading to a directory but I want to give the option for directory or database. My directory housing code works as it uses vB's upload function, just this stupid code doesn't and I have no idea about using vB's upload function to upload to the database.
Thanks in advance