Welcome Guest, Not a member yet? Register   Sign In
Calling a raw php file that is not a method nor controller?
#1

(This post was last modified: 05-15-2021, 09:57 PM by John mark bartholomon.)

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
Reply
#2

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
Enlightenment  Is  Freedom
Reply
#3

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#4

(This post was last modified: 05-16-2021, 09:38 PM by John mark bartholomon.)

(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.
Reply
#5

(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.
Reply
#6

(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...
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB