I have a device connected at my USB drive. There is an html form, that contains a tables with lots of rows and columns. I want to populate this table by using a php program, that reads the data from the USB port. How can I do this?
Read data from USB using PHP
Collapse
X
-
If the data is contained in a file, you can just use file_get_conten ts to read the file. You just would have to know where the USB drive got mapped. -
Perhaps I misunderstood. Are you talking about the User inserting a USB stick into a machine and then accessing a website which is being served from a different computer?
In this case, the best you can do is guess where the file is stored and redirect the User's browser to that file, but since your PHP script is server-side, all you can do is guess. You'd be better off serving the site directly from a USB drive, then making occasional AJAX calls to the main server to update the database.
This is just as well. Can you imagine the chaos that would ensue if web scripts could grab files off of clients' hard drives at will?Comment
Comment