Link to home
Create AccountLog in
Avatar of nikez2k4
nikez2k4Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Accessing file contents from local hard drive using PHP

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
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of triptec
triptec

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!
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
A question however would be:
Do you need access to yóur local drive only, or to any local drive?
-r-