Jump to content

Recommended Posts

hey

 

a newb question

 

how can I with PHP handle files that are in different folders?

 

currently, when I'm inside temp and need to reference the folder that contains temp, and a file in it, I use

 

../index.php

 

but sometimes it's not known at what level I am, so I could do a full reference, like http://example.com/index.php but that's not very wise I'm told

 

also, depending on the platform, I cannot use /index.php because that might not always be the root, where the Web content is

Link to comment
https://forums.phpfreaks.com/topic/169241-handling-files-from-different-folders/
Share on other sites

I am a bit lost on your question.

 

You can call files from different folders with php, and include them in the current script.

 

Such as:

<?php
//in current dir.
include("file.php");
//up a folder, a in the folder name: folder_name
include("../folder_name/file.php");
?>

 

Maybe you can rephrase your question.

 

-Lamez :)

Certainly!

 

because I'm using SSI, and have includes (php requires) I can't change those includes when I go up a directory or down a directory, it has to know itself where I'm currently calling it from, and based on that make linkes to ROOT/contact.php work (instead of ROOT/temp/contact.php)

Depending what you are trying to do with the referenced file you can either call it via a full path or referenced path.

 

If you are in /var/temp and you you need to access /var/file.txt you can either reference it is ../file.txt or /var/file.txt

 

If the file(s) are web accessible you could use the URL like for linking images.

Depending what you are trying to do with the referenced file you can either call it via a full path or referenced path.

 

If you are in /var/temp and you you need to access /var/file.txt you can either reference it is ../file.txt or /var/file.txt

 

If the file(s) are web accessible you could use the URL like for linking images.

 

that's whaat I thought, so I need to use full reference. it's okay, really. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.