473,387 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

load file name from URL cannot select folder

133 100+
Hi everyone,
This is my first PHP project and i am going a little nuts over this. lol.

I am trying to set the php file to load txt files from "files" DIR instead of the current DIR (where php is located) , if you know what i mean.

this loads from current DIR (where php is located)
Expand|Select|Wrap|Line Numbers
  1. //Load filename from URL
  2. if (isset($_GET['page']) && (file_exists($_GET['page'].'.txt'))) //If the url contains an existing filename
  3. {
  4.     $filename = $_GET['page'].'.txt';  //Load it
  5. }
  6. else
  7. {
  8.     $filename = 'files/'.'index.txt';  //Otherwise, default to index.txt
  9.     $htmltitle= 'Home';
  10. }
this script will load $filename = 'files/'.'index.txt'; but it will not get other txt files unless they are in current DIR
i have tried many different ways but without success..
Apr 16 '10 #1
4 2278
chathura86
227 100+
$filename = 'files/'.'index.txt';

is a relative path from the current php file you are executing so

you can use a absolute path to the file or make the relative path
with respect to the current php file

Regards
Apr 16 '10 #2
gobblegob
133 100+
@chathura86
Thanks but i am still confused, care to elaborate please?
Apr 16 '10 #3
chathura86
227 100+
can you show me your folder structure

Regards
Apr 16 '10 #4
gobblegob
133 100+
@chathura86
public_html/dev/board/index.php
public_html/dev/board/files/index.txt
public_html/dev/board/files/page1.txt
public_html/dev/board/files/page2.txt

files/ is where i would like to keep the text files.
Apr 16 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Cindy Liu | last post by:
Hi, If my xml resource file is directly under my project file, I have no problem to load that xml file via Assembly.GetManifestResourceStream. However, after I create a folder under the project...
26
by: Niggy | last post by:
I am trying to load a file from a dropdownlist, however I get a error saying a virtual path is required. An example selected value would be "../4900/myfile.doc". Any ideas - my code is. Dim...
6
by: sambuela | last post by:
How can I write message to the file located in the wwwroot directory? It seems that IIS protect these files. Let make me cannot do the I/O writing sucessfully. I try to open file's write...
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
6
by: Andy Sutorius via DotNetMonster.com | last post by:
Using the code below the browser just sits and spins. The dll is located in the root of the web app. System.Runtime.Interop is in the using statements. I have tried this in ASP.NET 1.1 and 2.0 and...
4
by: andrewcw | last post by:
I am moving some code forward from .NET 1.1. I was able to load the XSL file and perform the transform. The MSDN documentation looks like it should be easy. But I get a compile error. Ideas ?...
8
by: John Dunn | last post by:
Since currently we aren't allowed to have compiled XAML files embedded in C++ apps I'm using Markup::XamlReader::Load to dynamically load XAML files. This works perfectly fine with external files...
5
by: Alias | last post by:
Hi - I'm trying to implement a custom RoleProvider based on the SqlRoleProvider. I keep receiving a an error that it can't load type 'MyRoleTest.MyRoleProvider' when trying to load my...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.