Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 Yesterday 22:30:06
- Adams
- Plugin Author
- Registered: 2024-08-30
- Posts: 64
upload file inside plugin
Hello,
I have this code inside my plugin,
<div>
<form name=“myuploadform” method=“post” enctype=“multipart/form-data”>
Select file to upload:
<input type=“file” name=“fileToUpload” id=“fileToUpload”>
<i class=“fa fa fa-globe”></i> <input class=“link-button” type=“submit” value=“Upload File” name=“uploadsubmit” id=“uploadsubmit”>
</form>
</div>
public function hw_panel($evt, $stp) {
$available_steps = array( ‘list’ => true, ); if (!$stp or !bouncer($stp, $available_steps)) { $stp = ‘list’; }if (isset($_POST[“uploadsubmit”]))
{
$target_dir = “tmp/”;
echo realpath(“tmp/”); // correct path
The issue I’m having is that $_FILES[“fileToUpload”] returns null, no files (I’m sure the file is selected).
any idea, what I’m missing, what call back I need to to put the code somewhere else ?
BTW: same code outside the plugin works just fine.
Thank you
Offline
Re: upload file inside plugin
Depending on how you register your callback or handle it via bouncer() I’m surprised it runs at all. The “list” call is expecting a CSRF token to be passed too, so you’ll need to add form_token() to your form.
Other things to check:
- The file size doesn’t exceed your Txp prefs value for max file size.
- The file size doesn’t exceed the php.ini max size.
- The POSTed payload doesn’t exceed the max size.
- There aren’t any server-level modules installed that interfere with it (e.g. suhosin).
- All.permissions are correct.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Pages: 1