Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

readfile() on network share

Posted on 2006-07-17
7
Medium Priority
?
652 Views
Last Modified: 2013-12-13
Hi, I need to use the readfile function to read a file that is on a network share.

I tried everything on the php.net help page, but it still doesn't work. File_exists always returns false and the readfile function returns the following error:
-----------------
Warning: readfile(\\172.16.3.35\storage6\2006-07-07\SP1\SP1_2006-07-07_14-06-39_r10.wmv) [function.readfile]: failed to open stream: Invalid argument in C:\web\websites\auditmedia2005\_admin\download_recorte.php on line 81
File not found.
-----------------

The same script can read a file on the local HD, no problems.

My network share has a permisson to Everyone (Full Control). I have some delphi applications that can read the files without problems, so I'm think the problem is a permission setting on the network share for the user that runs IIS on the webserver.  Or can it be something else?

Please help!
Thank you

0
Comment
Question by:rogerbrito
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 17128561
Can you show the line of code?

As you are using \ and not /, you have to double them ...

so ...

<?php
readfile("\\172.16.3.35\storage6\2006-07-07\SP1\SP1_2006-07-07_14-06-39_r10.wmv");
?>

should be one of these ...

<?php
readfile("//172.16.3.35/storage6/2006-07-07/SP1/SP1_2006-07-07_14-06-39_r10.wmv");
?>

or

<?php
readfile("\\\\172.16.3.35\\storage6\\2006-07-07\\SP1\\SP1_2006-07-07_14-06-39_r10.wmv");
?>

Yes. 4 backslashes.
0
 

Author Comment

by:rogerbrito
ID: 17138011
Hi RQuadling, nope, it doesn't work:
-----------------------------
set_time_limit(0);
readfile("\\\\172.16.3.58\\storage2\\2006-06-28\\BEL\\BEL_2006-06-28_17-59-40_r15.wmv");

Warning: readfile(\\172.16.3.58\storage2\2006-06-28\BEL\BEL_2006-06-28_17-59-40_r15.wmv) [function.readfile]: failed to open stream: Invalid argument in C:\web\auditmedia2005\_admin\scripts\readfile.php on line 12
----------------------------

set_time_limit(0);
readfile("//172.16.3.58/storage2/2006-06-28/BEL/BEL_2006-06-28_17-59-40_r15.wmv");

Warning: readfile(//172.16.3.58/storage2/2006-06-28/BEL/BEL_2006-06-28_17-59-40_r15.wmv) [function.readfile]: failed to open stream: Invalid argument in C:\web\auditmedia2005\_admin\scripts\readfile.php on line 12

----------------------------

Any ideas
0
 

Author Comment

by:rogerbrito
ID: 17138493
I've found the answer!

It was  a permission issue. I just had to create an user account on the computer that has the remote share using the same username for the Anonymous User used by IIS on the webserver. Since windows generates a random password for this user, I had to change the password and create the new account using the same user/password. Give read permission to this user on the share and it works!

Thank you RQuadling for your help.

[]s
Roger
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Expert Comment

by:Richard Quadling
ID: 17144887
That's the joy of IIS. If you are on an old version of IIS, newer versions use a different user (I believe). Even though I'm on windows, I don't use IIS as it is WAY to complex for most requirements. I use Sambar Server - free from http://www.sambar.com - with a license option if you need the enhanced functionality (I don't). Support is good too.

Can support PHP ISAPI and FastCGI. Can support PHP4 and PHP5 simultaneously with very little issue.

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 17146515
No objection.
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 17168289
Closed, 250 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question