nikez2k4
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
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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!
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
- 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-
Do you need access to yóur local drive only, or to any local drive?
-r-
http://php.net/manual/en/features.file-upload.php