I have the following file structure
-- Plugins
-- inParent.php
---- Uploadify
------ inSame.php
------ Uploadify.php
This function was working smoothly till yesterday. But now, If I try to include the inParent.php in uploadify.php using require_once('../inparent.php), It giving me a silly error..saying...
Warning: require_once(../inParent.php) [function.require-once]: failed to open stream: No such file or directory in /home/user/public_html/plugins/uploadify/uploadify.php on line 3
But the file definitely exists...
The same code when used to include inSame.php shows no error and works perfectly..
I guessed that there could be file permission problem.. But everything is fine..all the related files have 755/644 permissions.
Also, the move_uploaded_file function has also stopped working.
All the code was working fine till yesterday. I hav'nt changed anything.
I have tried everything and dont know what exactly happened..
Please help me friends.. :( :(
They are all ways of including files. Require means it needs it. Require_once means it will need it but only requires it once. Include means it will include a file but it doesn't need it to continue.
The require_once keyword is used to embed PHP code from another file. If the file is not found, a fatal error is thrown and the program stops. If the file was already included previously, this statement will not include it again.
If you are using PHP 7.0 and above then the best way to navigate from your current directory or file path is to use dirname(). This function will return the parent directory of whatever path we pass to it.
I've googled and found this :
require_once __DIR__.'/../inParent.php';
In my case I had to write:
require_once dirname( __FILE__ ) . '/' . '../../inParent.php';
And that worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With