473,883 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading files from a different computer

Claus Mygind
571 Contributor
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
2 3134
nathj
938 Recognized Expert Contributor
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 Contributor
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
2708
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() method (exact signature not remembered) of the std::istream class ? When I'm reading the value in objects attribute (member variable), the read fails, but when I'm reading in a local variable value is successfully read as shown below: ..... any...
8
17049
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 with '\\' it doesnt work and exception is thrown (for example: \\MyComputer\DestDirectory). Even if the first and the second directories are actually the same- the File.Copy() doesn't work. Is there any way to copy a file to a different computer?...
2
3988
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 run it on my computer it runs fine. But when I compile the code and run it on different computer the code fails. I had similar problem when using Acrobat.CAcroAVDoc (DLL) which was solved by creating the DLL using the DLL's GUID.
1
967
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 easy way to change all of these references? If not, what is the hard way? Thanks Andy
11
7745
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 project files from the first computer onto a memory stick and then from the memory stick into my Visual Studio Projects folder on the second computer. But when I open Visual Studio on the second computer and try to create a project by pointing to...
2
983
by: Leszek | last post by:
Hello! How can i enumerate creation data of files at different computer? For example in %systemdir%?
10
2145
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 reading files. Based on the tutorials at www.python.org This "should" work. but im not sure what the issue is. ===SNIP=== import string
2
3854
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 files from these sub directories. I am using this code opendir(DIR, $lpath); @flist = readdir(DIR); closedir(DIR); when I do this @flist also contains files from sub directories and I do want that. How can I avoid reading files from...
1
1417
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
1907
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 developed it was making a duplicate of each file and then deleting the prefix on the copied file so the following statement could read a generic "filename":
0
9943
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11151
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10750
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9577
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7974
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7134
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4225
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3237
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.