Jump to content

handling files from different folders


wendu

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.