Hello guys I have project in office like this
I have system has data and not connected to internet , I can get data from it by using excel installed in pc1 , and pc1 is connected through hub with PC2 and have shared folder between them and both have windows 7 installed , but in Pc2 there is apache server and php "appserv"
My problem is when trying to get the content of excel file using php it show me the error
Failed to open stream : permission denied
How to make file readable from other pc?
http://i.imgur.com/sz36jA6.jpg

Dani AI

Generated

Short diagnosis: that PHP warning almost always comes from Windows file/share permissions or from the Apache service not having the right network credentials — not from PHP itself. In this setup (Excel on PC1, Apache/AppServ on PC2) check three things: the share + NTFS permissions on PC1, whether Excel has the file open (Excel creates a lock file starting with ~$), and which Windows account Apache is running under (services often run as LocalSystem and don’t inherit interactive user credentials).

Quick troubleshooting steps:

  • From PC2 test the share in Explorer or CMD: dir \\PC1\Share\file.xlsx. If that fails, fix firewall/share settings on PC1.
  • On PC1 ensure both the Sharing permissions and the Security (NTFS) permissions give the account read access (effective permission = intersection of share + NTFS).
  • Avoid mapped drive letters for services — use a UNC path (\\PC1\Share\file.xlsx).
  • If the file is open in Excel it may be locked; have the user close it or use a copy/sync approach.
  • If the Apache service runs as LocalSystem, change its Log On to a specific Windows account that has access to the share (or create an identical user/password on both machines in a workgroup). Then restart the Apache service.

Small PHP checks and an example reader (use an XLSX reader like PhpSpreadsheet for real parsing):

$path = '\\\\PC1\\Share\\file.xlsx';
var_dump(is_readable($path));
$fh = @fopen($path, 'rb');
if ($fh === false) { error_log('Cannot open ' . $path); }
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
$reader = IOFactory::createReaderForFile($path);
$spreadsheet = $reader->load($path);

As suggested, syncing can be the simplest production-safe fix: schedule a robocopy or use a sync tool so the server reads a local copy. Example robocopy command:

robocopy "\\PC1\Share" "C:\server\data" "file.xlsx" /copy:DAT /r:1 /w:1

Final notes: check Apache/PHP error logs and phpinfo() (look for open_basedir) for additional restrictions. Be mindful of storing credentials — prefer a dedicated service account with least privileges.

This will break in so many ways. I'd rethink my design. Maybe use a sync app that fires up and syncs the Excel file to the server when the file is changed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.