17

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.. :( :(

8
  • duplicate, check this answer stackoverflow.com/questions/11303033/… Commented Sep 3, 2012 at 6:32
  • @Serjio Thanks, but the code was working smoothly since eternity. What has caused this problem to occur? I know we can definitely include the files this way.. Then why the error ?? Commented Sep 3, 2012 at 6:37
  • 1
    @Spudley nope...I know case sensitivity is annoying but this time it is not causing the error.. I have said that the same code was working fine.. I did not change anything.... But suddenly this error started showing from yesterday.... Commented Sep 3, 2012 at 6:40
  • Are you opening the uploadify.php directly? or you are using another script to include it or something? Commented Sep 3, 2012 at 6:49
  • hey... why negative votes?? I am already frustrated by the problem.. now what is all negative voting stuff... Commented Sep 3, 2012 at 6:49

5 Answers 5

49

I've googled and found this : require_once __DIR__.'/../inParent.php';

Sign up to request clarification or add additional context in comments.

Comments

2

In my case I had to write:

require_once dirname( __FILE__ ) . '/' . '../../inParent.php';

And that worked!

Comments

1

This question is old, but for people like me who run across it, here is an answer from another part of Stack Overflow.

require_once($_SERVER['DOCUMENT_ROOT'] . '/inParent.php');

PHP require file from top directory

Comments

0

If it was working yesterday and you are certain you did not change anything, then try a server restart first.

Second, on require once try using the full path instead of .. I normally create a file with my root paths and referance those instead of using ./ and ../

1 Comment

actually, I have created a file named initialize.php containing the references.. But still I need to include that initialize.php using ../ Also, move_uploaded_file has also stopped working giving error that the folder does not exist...( it was also working fine before) Does this move_uploaded_file problem is also related to it?
0

In my case it is really weird:

  1. This Works perfect:

    require('../../the_folder/the_file.php');

  2. But PHP gives an error if i write that as this:

    require('../the_file.php');

Please see that in case 2 i do not go up two steps (../../) and then down to the folder, i directly go up one step (../).

Why is PHP giving the error Failed to open stream: No such file or directory in ... ? It is really weird.

This also works:

require(__DIR__.'/../the_file.php');

Thanks for the TIP.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.