Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can php read a client side text file?

Status
Not open for further replies.

bobrivers2003

Technical User
Oct 28, 2005
96
GB
If i had a text file "c:\test.txt" on a client side machine that contained a word on one line, is there a function in php that can open this file and read this word/assign it to a variable from a remote server?

If not is there another lanugage that can accomplish this?

This is for an application that allows specific machines to connect to a site, I can't use cookies/ipaddress and am quite happy with this solution if php or similar contains this function.


Many thanks
 
In general no, because he PHP is actualy running on a different machine.
Hhowever, the PHP server could read the file if it were mounted on some kind of network drive (a share under windows for example), or if the local machine also had a web server running which could serve up the file to the remote machine.
If you want a longer discourse write back !

Regards
 
Its looks like I will have to try something else.

Might be a good read:

The application is a php based request tool that has two types of users, regular and admin. Regular users sign on and if they have a request/problem fill in the form and click submit. Any admins that are logged in (on separate machines) will have a pop up appear that'll say New Request Added, they sort the problem and submit a response. The theory is to stop people randomly approaching us (physically) and asking stupid questions when they fell like it. Make it electronic to allow a bit of control. And the best thing is that is works!!

However there is an issue with the signing on to the tool. Currently I have a user name and password login, admins create an account, user log on. This tool is intended for computers on a specific intranet within work. The bosses want user to login on to their desktops once and be able to have access to this tool. If a user tried to access the tool at home it would deny access.

Here was my thought. Run a batch file that is located on each workstation that retreives the hostname, user id and any other unique info that maybe of use and saves it to a text file. A browser is then launched and somehow I want the web tool to obtain the data in the text file and compare it to a db that will already contain this info. If it matches allow access if not kick em off. The difficulty I am having is passing the info to the server. I will have a think maybe Java has the answer?

I know others have had difficulty with automatic authentication and have been suggested LDAP, but I haven't a clue what this is but might be a problem getting it to every work station whereas a batch or java file would be quite simple.

thanks for the help. Very much appreciated.

Regards
 
how about using cookies coupled with an IP address check? (cookies for single-sign-on and the IP address check to prevent home-users - this could even prevent vpn traffic if you knew the vpn address pool)

LDAP might work but it sounds like a sledgehammer to crack a small nut.
 
By default Java wont let you see local files but you can create your own secutity wrapper class which will allow you to do this. I havn't done this and I bet things like XP SP2 will get in the way.
I had another thought. If you issue each user with a token file which for example was an MD5 of a string (with a secret value concatated. So you might have 45566...fred and the server compared 45566... with md5(fred+secretvalue) you could either have a click in an email do the registration which then deletes the value from a db to prevent it ever being done again (and so not at home) or you could have a file uploaded by the user and again deleted from a db.

hope this makes sense, it's a bit like a registration/confirmation pair but without the manual registration.
 
Pretty interesting stuff,

However with the md5 secret value combo although registration would be done once wouldn't the user be able to gain access from another machine?

The file upload sounds quite good but I know that the powers above me will have a moan about server security and that it can only be readonly.

I have had a thought about md5 stuff but it still comes down to the divide between client and server. On the local machine I can get unique ids usernames etc but can't send them to the server, the server can do all the validation but can't get the data from the clients machine!!


How secure is an ip address check?
 
sorry missed the bit about allowing access from a single machine.
I belive that the variables that get passed up to the server include the computername and the ip address, you could perhaps make some decisions around them on access.
 
I have just had a meeting and reckon I can convince the whole username/password remember settings via cookies thing.

Quite alot of politics going on!!

Application should be finished in a week or so will let you know what method I ended up using.

Thanks for everyones help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top