问题
this is my file structure in my modules
tmpl
default.php
helper.php
mod_helloword.php
mod_helloword.xml
i have this form in default.php file
<form action="" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
i want to pass it after click on submit to heper.php file in that form action attribute must set to what ??
回答1:
You don't need to set an action, you can simply give it a name. So you form would look something like this:
<form name="submit" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
Then your helper.php :
class ModHelloWorldHelper {
public static function submit($file) {
// some code goes here
}
}
Then your mod_helloworld.php (which calls the function in the helper.php):
$input = new JInput;
$post = $input->getArray($_POST);
if ($post["submit"]) {
modHelloWorldHelper::submit($file);
}
Please note that you will of course have to make a few changes to suits your needs as the code above is just there to give you a small head start
来源:https://stackoverflow.com/questions/20659236/how-to-set-action-to-form-in-joomla-modules