Re: Displaying files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15 Aug 2008, at 14:26, Dan Shirah wrote:
Because as I mentioned before PHP runs as a different user to your browser.

-Stut

Stut,

Are you referring to this?

"If you're using IIS then it's the IUSR_machine user which doesn't have access to the network by default"

The IUSR_SERVERNAME account is what it should be connecting as whether I'm using PHP/Javascript/HTML, unless specifically set in a connection string such as the database connections. But, the initial calls always come from IUSR_SERVERNAME.

You need to understand that there are 2 sides to a web-based application, the client and the server. When you link the browser to a file (as in your HTML and JS code below) it's the *client* that's accessing the file. Neither IIS nor PHP get involved in that. This works because the browser is running as you and has sufficient permissions to access that network location.

When you try to do the same with PHP it is running as the IUSR_SERVERNAME user which, by default and for good reason, cannot access network shares in that way. The link I gave you should give you enough information to enable the required access for that user, but you might want to think carefully before doing so since it's disabled by default for security reasons.

-Stut

Thiago,

HTML WORKS
<a href=\\server\folder\file.xls target="_blank">Open</a>

Javascript WORKS
function openWin(folder,file) {
 var LeftPosition = (this.screen.width) / 2;
 var TopPosition = (this.screen.height) - this.screen.height;
 var Height = (this.screen.height) - 90;
 var Width = (this.screen.width) /2 - 10;
MyWin = window.open(\\\\server\\"+folder+"\\"+file +"\.xls","ViewImage","scrollbars=yes, status=yes, resizable=no,top="+TopPosition+",left="+LeftPosition+",width="+Width +",height="+Height+"");
 MyWin.focus();
}

PHP DOESN'T WORK
$filename = "\\\\server\\".$folder."\\".$file.".xls";
header("Content-Type: application/x-msdownload");
readfile($filename);

I put all three of these examples into the exact same page. The HTML and Javascript open the file without any problems, but PHP cannot open it.



--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux