Hi Guys
Thank you for your reply.
I have managed to sort out this issue, which was that i was actually making this declaration in the main module declaration file under the function action( as was explained in the module tutorial).
I have removed the code from there and set up a new action.defaultadmin.php file which is where I an now writing the following code section
Code: Select all
echo $this->CreateFormStart($id,"do_upload",$returnid,"post","multipart/form-data");
echo $this->CreateInputHidden($id,"upload","upload");
echo "<table>";
echo " <tr>";
echo " <td>Choose the vacancy file to upload</td>";
echo " <td>";
echo $this->CreateInputFile($id,"uploadedfile","'text/csv','application/csv','application/excel','application/vnd.ms-excel','application/vnd.msexcel'",'25');
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td colspan=2>";
echo $this->CreateInputSubmit($id,"submit","Upload File");
echo " </td>";
echo " </tr>";
echo "</table>";
echo $this->CreateFormEnd();
This is now calling the action.do_upload.php file correctly.
However i now have another issue which is....how do I actually access and move the file which is being uploaded. I could do this is php by the following code and actually want to know what is the CMS Made Simple equivilent for this
Code: Select all
//set the destination folder
define('target_path','TestingFile/');
//Test to see if the file has been picked up correctly--comment out before actual deployment
print_r($_FILES);
//Set the allowed files type to be uploaded (currently only CSV file types are allowed)
$ftypeAllowed = false;
$fileTypes = array('text/csv','application/csv','application/excel','application/vnd.ms-excel','application/vnd.msexcel');
//Check to see if the file type being uploaded is the correct type
foreach($fileTypes as $types){
if($types == $_FILES['uploadedfile']['type']){
$ftypeAllowed = true;
break;
}
}
if($ftypeAllowed){
$file ="TestFile.csv";
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],target_path.$file);
echo("File Uploaded Successfully");
}
else{
echo("This file type is not allowed to be uploaded");
}
The reason I'm asking is that when the action.do_upload.php file is being called, it seems to me that it is losing the reference of the file input box and returning a null value.
Also if possible could you explaing to me that in this type of scenario is there any way to actually check if a form post has been done or is that taken for granted.
Once again thank you for your help