File uploading in a Directadmin plugin is possible, and there is nothing difficult if to say in general. Let me show some basic moments with the help of which you can achieve the desired.
Directadmin does not add any special requirements for it. So you are free to use any which you may find. Here is below a simple example of such a form:
<form method="POST" enctype="multipart/form-data" action="?"> File to upload: <input type="file" name="upfile"><br> Notes about the file: <input type="text" name="note"><br> <br> <input type="submit" value="Press"> to upload the file! </form>
By default Directadmin uses it's own directory for temp files. The directory is located in /home/tmp/. Of course you may symlink /tmp to /home/tmp for more security.
There are some critical differences which should be considered when writing a plugin for Directadmin. There are no such variables as $_POST, $_GET, $_FILES, etc. We may use the only existing $_SERVER, which usually contains all of them as strings. So we need to do some parsing:
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) { parse_str($_SERVER['QUERY_STRING'], $_GET); } if (isset($_SERVER['POST']) && $_SERVER['POST']) { parse_str($_SERVER['POST'], $_POST); }
Information on an uploaded file will be stored in $_POST var here. And it will be only a full path to a temporary stored file in /home/tmp/. In our example it will be: $_POST['upfile']
So, the simple PHP code:
<?php var_dump(is_file($_POST['upfile'])); exit; ?>
would result in priting of simple output:
bool(true)
Since now you know how to upload files in a Directadmin plugin. Copy a file to a location of your needs, and have fun.
That should be considered that as for now Directadmin will chown an uploaded file to nobody:nobody and set restrictive permissions to 600. And to copy such a file your plugin should run as root via a suid wrapper.