Open a file using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ccorlett7
Forum Newbie
Posts: 3
Joined: Wed Mar 23, 2011 9:19 am

Open a file using PHP

Post 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
skylark2
Forum Commoner
Posts: 32
Joined: Wed Jun 16, 2010 6:00 am

Re: Open a file using PHP

Post 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...
ccorlett7
Forum Newbie
Posts: 3
Joined: Wed Mar 23, 2011 9:19 am

Re: Open a file using PHP

Post by ccorlett7 »

it is all running just on my machine so I am essentially the client and server....using WAMP server to run it.
ccorlett7
Forum Newbie
Posts: 3
Joined: Wed Mar 23, 2011 9:19 am

Re: Open a file using PHP

Post 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
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

Re: Open a file using PHP

Post 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.
User avatar
afr_dnf2011
Forum Newbie
Posts: 14
Joined: Mon Mar 21, 2011 8:20 pm

Re: Open a file using PHP

Post 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;
}
?>
Post Reply