Read Text File From Client Machine

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
avrgod
Forum Newbie
Posts: 3
Joined: Wed Sep 25, 2013 5:15 am

Read Text File From Client Machine

Post by avrgod »

Hi Developers,

I want my hardware to interact with web.
So for that i have a desktop application at client machine which will generate a text file after getting data from hardware.

Now i want that text file to be read by server and get its data so that i can manipulate data on server and make it accessible from anywhere.

I am not much into PHP but i can make it work with some HELP, Suggestion or Example.

So Please give your ideas for the same. :)

Thanks in advance!!!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Read Text File From Client Machine

Post by Celauran »

You'll need to have the user attach the file to a form. You cannot read files on a user's machine for fairly obvious security reasons.
avrgod
Forum Newbie
Posts: 3
Joined: Wed Sep 25, 2013 5:15 am

Re: Read Text File From Client Machine

Post by avrgod »

Thanks Celauran :) for your quick reply.

But i need to do it without any user. Can u suggest any other method or something to achieve it without user attach the file to a form??
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Read Text File From Client Machine

Post by Celauran »

As I mentioned already, you can't. I don't mean shouldn't, I mean can't.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Read Text File From Client Machine

Post by AbraCadaver »

Have the client machine either copy the file to a share on the server or some other intermediate share that is accessible to both the client and server. Maybe have this copy done after the desktop app creates the text file.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
avrgod
Forum Newbie
Posts: 3
Joined: Wed Sep 25, 2013 5:15 am

Re: Read Text File From Client Machine

Post by avrgod »

Thanks AbraCadaver :)

I got your point.
Can you suggest how to share that text for both client and server?

I mean how to achieve that? (After reading you reply i googled it but nothing much i got)
ArunSM
Forum Newbie
Posts: 1
Joined: Sat Mar 29, 2014 6:03 am

Re: Read Text File From Client Machine

Post by ArunSM »

One of the way to achieve it is to store your generated file on some File Server / DB Server (Anyhow this can again only be written in Client Application) if you need automation.

Workaround if you cannot modify your application: You can write a watch script which will be monitoring your generated file. Upon any change trigger a request which sends your file to some safe location (again it needs to be server). If you feel data update happens too often then setup CRON command to do this job after regular interval.

Again there may be ways to do it. These are few easy ways though.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Read Text File From Client Machine

Post by Christopher »

avrgod wrote:Hi Developers,

I want my hardware to interact with web.
So for that i have a desktop application at client machine which will generate a text file after getting data from hardware.

Now i want that text file to be read by server and get its data so that i can manipulate data on server and make it accessible from anywhere.
I think the first question is whether this is a push or pull architecture. Given what you have described, I think it makes the most sense for the desktop application to push the data to the web server. To do that you just need to implement a web service on the web server. Then the applications can push data whenever they need to. The central web server can the process that data and make it available as needed. Use SOAP or similar for you web service. I would recommend using a HTTPS connection as well. Also, the web server can return data to the desktop application in the response if needed.
(#10850)
Post Reply