473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Reading files from a different computer

Claus Mygind
571 512MB
Using the sample script from the php manual
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dir = "/etc/php5/";
  3.  
  4. // Open a known directory, and proceed to read its contents
  5. if (is_dir($dir)) {
  6.     if ($dh = opendir($dir)) {
  7.         while (($file = readdir($dh)) !== false) {
  8.             echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
  9.         }
  10.         closedir($dh);
  11.     }
  12. }
  13. ?>
  14.  
I can read files on the web server. But I would like to read files from a different computer on our network (that is not set up as a server).

I am using php version 5.3.3.0

Are there setting in the php.ini files that I must change? Or what else do I need to do.
May 9 '11 #1

✓ answered by Claus Mygind

Thank you for your response. Actually you do not have to have another server. I finally figured it out.

1. On the computer you want to access you simply set up an account and pass word with the UAC (user account control) found in the window's control panel.

2. The user account and password is the name of the computer you use as your web server and the password you use to log into the web server.

3. On the web server you (IMPORTANT!) run your web server as a service and voila there you have it.

4. You can now read the files on the other computer. You can access the remote computer using the format below(pay attention to the slashes).

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $cDir = "//remote computer's name/drive/folder/";
  4.  
  5. if(!$dh = @opendir($cDir)) return;
  6.  
  7. while (false !== ($obj = readdir($dh))) {
  8.  
  9.    echo "filename: $obj : filetype: " . filetype($cDir . $obj) . "<br />";
  10.  
  11. }
  12.  
  13. closedir($dh);
  14.  
  15. ?>
  16.  

2 3117
nathj
938 Expert 512MB
I think that the second server will need to be set up to allow some sort of connection. Possibly an open port or even set it up as a webserver that can then be accessed.

I've never deon this with PHP but has seen many systems developed in Java do just this usin a separate fileserver. However, the architecture side of things has always been a bit of a mystery to me. Do you have any network guys there who can help with this as I think the issue is network rather than php.
May 12 '11 #2
Claus Mygind
571 512MB
Thank you for your response. Actually you do not have to have another server. I finally figured it out.

1. On the computer you want to access you simply set up an account and pass word with the UAC (user account control) found in the window's control panel.

2. The user account and password is the name of the computer you use as your web server and the password you use to log into the web server.

3. On the web server you (IMPORTANT!) run your web server as a service and voila there you have it.

4. You can now read the files on the other computer. You can access the remote computer using the format below(pay attention to the slashes).

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $cDir = "//remote computer's name/drive/folder/";
  4.  
  5. if(!$dh = @opendir($cDir)) return;
  6.  
  7. while (false !== ($obj = readdir($dh))) {
  8.  
  9.    echo "filename: $obj : filetype: " . filetype($cDir . $obj) . "<br />";
  10.  
  11. }
  12.  
  13. closedir($dh);
  14.  
  15. ?>
  16.  
May 14 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: WahJava | last post by:
Hi developers, I'm running GCC (GNU C/C++ Compiler shipped with Fedora Core 2). I've written a program using IOStream classes, in which I'm reading files in ios::binary mode. I'm using read()...
8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
2
by: okaminer | last post by:
I writing VB.NET Code using Acrobat 6 API functions and my problem is with the following code: _formApp = New AFORMAUTLib.AFormAppClass _acroForm = _formApp.Fields The problem is that when I...
1
by: a | last post by:
I moved all of my code (ASP.NET, Framework 1.1, VS2002) to a different computer. Of course, when I try to open the site the SLN file and the code behind files point to the old site. Is there an...
11
by: Dave | last post by:
I copied the project files from an ASP.NET project on one computer and want to create the project on another computer, There is no connection between the two computers so I simply copied the...
2
by: Leszek | last post by:
Hello! How can i enumerate creation data of files at different computer? For example in %systemdir%?
10
by: Johhny | last post by:
Hello All, I am working my way through learning python as a language. I am having some issues with something that looks right and does not work. I am trying to get myself more familure with...
2
by: supra91 | last post by:
Hi, I have to read files from the parent directory and delete those files. This parent directory contains logs files. This directory also contains some sub directories and I do not want to delete...
1
by: vuyyurus | last post by:
Need help in reading a different word file which has table with rows and columns and write to different word document in certain table with rows and cloumns.
4
by: Miner Jeff | last post by:
Hello, I have a basic question about reading files. I have several data files where the filenames are identical except for a short (3 character) prefix. I inherited this code and the person who...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.