?
Solved

Accessing file contents from local hard drive using PHP

Posted on 2006-03-20
5
Medium Priority
?
674 Views
Last Modified: 2008-02-01
Hi guys,

I am trying to load the contents of a txt file into a variable so I can store them on my server. The thing is I don't know how to access the file which is on my PC using a PHP script on a server.

I have a form with a file upload box which, when submitted, posts to a PHP page. I then have taken the output from the upload box - C:\\text_text.txt - and stored it in a variable.

From there I have no idea - I need to be able to open that file (on my pc NOT the server) and read it's contents.

Any ideas?

Thanks,
MOZ
0
Comment
Question by:nikez2k4
5 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 2000 total points
ID: 16234805
You cannot, unless you install a ftp-server or other way php is allowed to access your filesystem.

What is the problem with just uploading the file?

-r-
0
 
LVL 1

Expert Comment

by:triptec
ID: 16236456
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 16236486
Roonaan is right (of course!). You might like to start here: http://www.php.net/manual/en/features.file-upload.php

I guess you could turn it around and run a web server on your PC and let your server pull whatever it wants from your PC. You might have a few, erm, security issues with that though!
0
 
LVL 17

Expert Comment

by:davebytes
ID: 16236951
The only solution would be:
- set up dynamic DNS for your home machine
- set up a minimal apache (or lighttpd or other 'tiny' webserver) off a hidden port on your box.
- mod firewall(s) to allow the connection from your server (fixed IP? if so, use that specifically to filter!) back to your http server.
- make the ONLY thing in local httpdocs be your text_text.txt file
- use CURL or other file-retrieval to get http://your.dyndns.dom/text_text.txt

-d
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 16237194
A question however would be:
Do you need access to yóur local drive only, or to any local drive?
-r-
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question