My little changes now this:
in mydownloads_submit.html I have changed the definition of form adding
enctype="multipart/form-data
and a line in html table after url entry:
<tr><td class="head">
<b>File locale:</b></td>
<td class="odd">
<input type="file" name="fileutente" />
</td>
</tr>
<tr>
after in file submit.php in mydownload module directory I have modified
// Check if URL exist
if (($HTTP_POST_VARS["url"]) || ($HTTP_POST_VARS["url"]!="")) {
$url = $HTTP_POST_VARS["url"];
}
in:
// Check if URL exist
if (($HTTP_POST_VARS["url"]) || ($HTTP_POST_VARS["url"]!="")) {
$url = $HTTP_POST_VARS["url"];
}
if (!empty($_FILES['fileutente'])) {
$file_name = basename($_FILES['fileutente']['tmp_name']);
$file_info = pathinfo($_FILES['fileutente']['name']);
# add extension
if ($file_info['extension']) {
$file_name = $file_name.".".$file_info['extension'];
}
# compose url path
$url = XOOPS_URL."/modules/mydownloads/uploads/".$file_name;
if (move_uploaded_file($_FILES['fileutente']['tmp_name'],"uploads/".$file_name)) {
$debug_txt = "File uploaded";
}
else {
$debug_txt = "Error while upload file:<br/>".$_FILES['fileutente']['error'];
}
}
This method admit that users can add simple a link or, in case that gives you a file, upload a file in a directory.
I am trying to work on automatic deletion of not approved file. Also I'm not sure that the uploaded file don't write over another file
but now work