Page 1 of 1

Open a file using PHP

Posted: Wed Mar 23, 2011 9:24 am
by ccorlett7
Hi guys, I'm a newbie here looking for some help with my PHP.

I've created a button which will allow the user to click on, that popups the explorer window enabling them to navigate to a file and, in turn, open that file in a specified piece of software.

I've made it possible to click a 'browse' button and then browse for a file to upload, but is this other way possible?

I would want them to be able to navigate and select a '.kml' file that will open using Google Earth

Cheers

Re: Open a file using PHP

Posted: Wed Mar 23, 2011 9:38 am
by skylark2
Is the file they will be opening on the server or the client?

Fellow newbie who keeps having to wrap her brain around where and when the php is actually being executed...

Re: Open a file using PHP

Posted: Wed Mar 23, 2011 9:42 am
by ccorlett7
it is all running just on my machine so I am essentially the client and server....using WAMP server to run it.

Re: Open a file using PHP

Posted: Thu Mar 24, 2011 10:06 am
by ccorlett7
anybody got an idea as to how i can achieve this?

I have heard of and looked into php file manager but this doesnt make any sense to me.

cheers

Re: Open a file using PHP

Posted: Thu Mar 24, 2011 7:33 pm
by danwguy
Paste up the code that you do have that works and we can take a look and see where the problem lies. It almost sounds to mee like you need to set file associations on your machine if they are browsing files and opening them on your computer.

Re: Open a file using PHP

Posted: Sun Mar 27, 2011 12:22 am
by afr_dnf2011
the following code may help you.

Code: Select all

<?php
$txt_file = "file1.txt";
$f = fopen($txt_file, "r");
while ( $line = fgets($f, 1000) ) {
print $line;
}
?>