PHP Classes

url instead of path

Recommend this page to a friend!

      Create File By Parsing Dir  >  All threads  >  url instead of path  >  (Un) Subscribe thread alerts  
Subject:url instead of path
Summary:Writing the URL of files instead of the server path.
Messages:9
Author:Mark
Date:2005-06-13 02:42:55
Update:2005-06-14 12:37:18
 

  1. url instead of path   Reply   Report abuse  
Picture of Mark Mark - 2005-06-13 02:42:55
Hi Rochak,

Is it possible to write the list in the saved file as a URL rather than the server path - like http://localhost/pictures/picture.jpg

If not can the file names be saved without including the server path? Eg: picture.jpg and not c://directory/path/to/picture.jpg

Thanks.

  2. Re: url instead of path   Reply   Report abuse  
Picture of Er. Rochak Chauhan Er. Rochak Chauhan - 2005-06-13 04:33:28 - In reply to message 1 from Mark
Try using....

$_SERVER['SERVER_NAME']
Instead of $_SERVER['DOCUMENT_ROOT'] in the class

  3. Re: url instead of path   Reply   Report abuse  
Picture of Mark Mark - 2005-06-13 12:25:08 - In reply to message 2 from Er. Rochak Chauhan
Thanks Rochak. That didn't work. I'm wondering where in the script the file list names are created to write in the CSV. Then maybe I could set a $urlPath='http://192.168.0.1/directory/'; and have that substituted for the /apache/htdocs/directory/ in the list (?).

Regards,

Mark.

  4. Re: url instead of path   Reply   Report abuse  
Picture of Er. Rochak Chauhan Er. Rochak Chauhan - 2005-06-13 12:39:39 - In reply to message 3 from Mark
Hi Mark,
This is how class works.... when you call setRootDirectory($dirPath)... what ever you pass in $dirPath get appended in the beginin of the file name. I guess if i am gettin it write all you gotta do is ..
setRootDirectory('http://www.domain.com')

And... REPLACE

$this->rootPath = $_SERVER['PATH_TRANSLATED'].$this->slash;

and

$this->rootPath = $_SERVER['DOCUMENT_ROOT'].$this->slash;


with

$this->rootPath = $dirPath.$this->slash;




GOOD LUCK !!

  5. Re: url instead of path   Reply   Report abuse  
Picture of Mark Mark - 2005-06-13 14:31:23 - In reply to message 4 from Er. Rochak Chauhan
Thanks again Rocjak. Still doesn't work. It still writes lists like:
C:/apache/apache2/htdocs/recorder/uploads/1118620804.ogg
C:/apache/apache2/htdocs/recorder/uploads/1118620805.ogg

rather than:
192.168.0.1/recorder/uploads/111862 ...
192.168.0.1/recorder/uploads/111862 ...

I tried declaring a variable
$urlPath='$dirPath'; and '$rootPath'
and changing
$fileContents .= $rootPath.$file.$seperator;
to
$fileContents .= $urlPath.$file.$seperator;

but what resulted was a list like this:
1118620804.ogg
1118620805.ogg

Mark.

  6. Re: url instead of path   Reply   Report abuse  
Picture of Mark Mark - 2005-06-13 14:49:13 - In reply to message 5 from Mark
Rochak,

sorry about the typo. I mis-spelled your name. Sometimes with my bad typing I type Marl for Mark. :-)

  7. Re: url instead of path   Reply   Report abuse  
Picture of Er. Rochak Chauhan Er. Rochak Chauhan - 2005-06-14 05:13:25 - In reply to message 6 from Mark
Dont worry about the name... Its ok !! and buddy you have inspired me to modify my class... yeah u did... now Download the new version of this class...and the example script... I have added the functionality to specify your own path (inyour case url) to be written in the file !

Hope it helps !

Rochak.

  8. Re: url instead of path   Reply   Report abuse  
Picture of Mark Mark - 2005-06-14 12:00:16 - In reply to message 7 from Er. Rochak Chauhan
Cool. It worked perfectly.

All I could suggest now is that the class be set up in such a way that users may choose whether the want the lists with path, url or file names only.

In my case I'd like a list of URLs which can be parsed by another app. Someone else may want to use the path info while others might just require the file list.

Good work and thanks for making it available.

Mark.

  9. Re: url instead of path   Reply   Report abuse  
Picture of Er. Rochak Chauhan Er. Rochak Chauhan - 2005-06-14 12:37:18 - In reply to message 8 from Mark
Great, I am glad it works for you ! Buddy i did all that you are suggesting now.... if you call the function like this ==> setRootDirectory($dirPath, $pathToWriteInFile)
now the files will be appended to $pathToWriteInFile string (whether its URL or another dirpath)

and

is you call it like this ==> setRootDirectory($dirPath)

then all the files will be appended after the original path name !

pretty Simple eh ?