CodeIgniter Forums
Calling a raw php file that is not a method nor controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Calling a raw php file that is not a method nor controller? (/showthread.php?tid=79234)



Calling a raw php file that is not a method nor controller? - John mark bartholomon - 05-15-2021

Summarry:
I am submitting a form to a php file tat is not a method or controller(it is a raw php file)

Problem:
When I submit the form it says that  "Controller or its method is not found: \App\Controllers\Export::policyfile_txt.php" 
but the case is i do not want it to be read or identified as an controller a method just a RAW php file


My file structure:

ROOT-public - export - policyfile_txt.php (url will be "public/export/policyfile_txt.php")
                                   -policyfile_pdf.php (url will be "public/export/policyfile_pdf.php")

the view that submits to the txt or pdf file
                                <button style="background-color:white;border:none" class="m-1"type="submit" formaction="../public/export/policyfile_pdf.php" formtarget="_blank"><i class="far fa-file-pdf"></i><span style="margin-left:7px;">Export As <b>Pdf</b></span></button>
                                <button style="background-color:white;border:none" class="m-1"type="submit" formaction="../public/export/policyfile_txt.php" formtarget="_self"><i class="far fa-file-alt"></i><span style="margin-left:7px;">Export As <b>Txt</b></span></button>


Is there a way to do this , feel free to give suggestions,recommendations,and any sort of help


RE: Calling a raw php file that is not a method nor controller? - paliz - 05-16-2021

To call raw file in contoller you should use
helper()
Create g_helper and put it helper folder then go to h
Controller call
helper("g")

Finally call function in g_helper file


RE: Calling a raw php file that is not a method nor controller? - includebeer - 05-16-2021

CodeIgniter's .htaccess file is messing with your URL and redirect it to the front controller (index.php). I think the easiest way to do this would be to put those files in a separate folder outside of CodeIgniter's structure.

Or if you know how to do it, you can probably add an exception in the .htaccess file to not redirect those URL to index.php but I don't know how.


RE: Calling a raw php file that is not a method nor controller? - John mark bartholomon - 05-16-2021

(05-16-2021, 03:09 AM)paliz Wrote: To call raw file in contoller you should use
helper()
Create g_helper and put it helper folder then go to h
Controller call 
helper("g")

Finally call function in g_helper file

1.)quite unclear on what do you mean by create g_helper do you mean by a folder
2.)what do you mean by controller call helper(“g”)  , also go to h (where did h come from)
just clarifying some things btw thanks for your insight too.


RE: Calling a raw php file that is not a method nor controller? - John mark bartholomon - 05-16-2021

(05-16-2021, 12:56 PM)includebeer Wrote: CodeIgniter's .htaccess file is messing with your URL and redirect it to the front controller (index.php). I think the easiest way to do this would be to put those files in a separate folder outside of CodeIgniter's structure.

Or if you know how to do it, you can probably add an exception in the .htaccess file to not redirect those URL to index.php but I don't know how.
Yes that is one solution to move my file outside of my codeigniters root folder but i beleive there is actually a proper way to state a file that is a method nor a controller.ty for your insight on this too.


RE: Calling a raw php file that is not a method nor controller? - includebeer - 05-17-2021

(05-16-2021, 09:37 PM)John mark bartholomon Wrote: Yes that is one solution to move my file outside of my codeigniters root folder but i beleive there is actually a proper way to state a file that is a method nor a controller.ty for your insight on this too.

By default, everything is fed to index.php (the front controller). I think the only way to bypass this behavior is by editing the .htacess file in the public folder. But I’m no expert in apache config...