File Access

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
MbahGondrong
Forum Newbie
Posts: 7
Joined: Wed Apr 22, 2009 2:37 pm

File Access

Post by MbahGondrong »

How can I access file in other folder in a php file in linux? what is the correct syntax?

It looks different than windows syntax.

Thanks.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: File Access

Post by jaoudestudios »

It should be very similar, apart from windows is more flexible with forward/back slash where linux only accepts a forward slash. You can access your file relatively.
i.e. include('your/file.php');
MbahGondrong
Forum Newbie
Posts: 7
Joined: Wed Apr 22, 2009 2:37 pm

Re: File Access

Post by MbahGondrong »

I already tried using normal syntax but it keeps getting error when tested in browser.

The problem is, the php file is on a folder named generator, it used 2 include TConnection.php and class.file.php which is located in the parent folder from generator.

So normally I used something like this right:

include ('../TConnection.php');

include ('../class.file.php');

Is this correct?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: File Access

Post by jaoudestudios »

Yep that looks good.

Try the absolute path.
i.e. /var/www/vhosts/domain/htdocs/yourfile.php
MbahGondrong
Forum Newbie
Posts: 7
Joined: Wed Apr 22, 2009 2:37 pm

Re: File Access

Post by MbahGondrong »

Alright, gonna try it then.
Post Reply