Jump to content

PHP download network location


Go to solution Solved by requinix,

Recommended Posts

Hello people, 

 

i really need help..

 

Im programming an intranet for my employer and now i face a problem.

 

The server runs on Windows 2008 R2, the website is online and PHP works and also my sql database. 

 

Now my employer wants me to put links online which lead to a network location. Everybody has access to this server but i cant figure out how to write the php code to point to that direction. 

 

The Website runs on the server DERFPFVM072 and the files to download are on the server DERFNAP001/all.rb.

 

I tried chdir but it doesnt work, i tried normal html but it didnt work. 

 

Is there a way to make the files downloadable without moving them to the server?

 

Note: Moving the files to the server would have been my suggestion but this would lead to a lot of work to change the licenses (the company i work for has A LOT OF LICENSE FOR EVERY LITTLTE THING) to let the employees have access to the shared folder on the server.

 

Apparently, this is what my code looks like:

 

<?php
error_reporting(E_ALL);
 
$dir = opendir("//DERFPFNAP001/all.rb/Useranleitungen");
while (($file = readdir($dir)) !== false) 
{
echo '<li><a href="//DERFPFNAP001/all.rb/Useranleitungen/'.$file.' " type="video/mp4">'.$file.'</a></li>';
}
closedir ($dir);
?>
</ul>
 
Im pretty new to working with php and have never done something like that before. 
 
When the files are on the server the download work with:
 
<?php
chdir('./howtos');
foreach(glob('*') as $key => $file) {
echo '<li><a href="/intranet_data/abteilungen/it/howtos/'.$file.'">'.$file.'</a></li>';
}
?>
 
 
Thanks for your help beforehands ;)

 

Link to comment
https://forums.phpfreaks.com/topic/297505-php-download-network-location/
Share on other sites

Right, I forgot to ask what "doesn't work" means...

 

There's nothing in your code that would cause random slowdowns (that aren't related to network problems). Is there more code? Have you figured out where in the code the slowdown is?

It doesnt show the files. 

There is no content. 

 

I mapped the network location in the server as a admin and have full right to the mapped locations. 

 

<?php
chdrive ("Z:");
chdir("./Vorlagen");
echo getcwd();
foreach(glob('*') as $key => $file) {
echo '<li><a href="Z:/Vorlagen/'.$file.'" download="Z:/Vorlagen/'.$file.'">'.$file.'</a></li>';
}
?>
 
I want to provide the files for the emloyees to download them. Is there something in my code thats wrong?
 
Further Info: 
I mapped the Folder "Vorlagen" directly and the mapped Network Location hat the letter "Z" on my server.
The files are lying on a NetAPP Storage (NDMP)
 
On the Storage the structure to the files is: "DERFPFNAP001/all.rb/Vorlagen/$files"
  • Solution

1. Mapping the location to a drive will not affect permissions.

2. You can only link people to Z: if everybody has that location mounted as that drive letter.

 

Skip the chdrive (which doesn't even exist), skip the chdir, and give glob() the full path.

<?php
foreach(glob('//DERFPFNAP001/all.rb/Vorlagen/*') as $key => $file) {
echo '<li><a href="Z:/Vorlagen/'.$file.'" download="Z:/Vorlagen/'.$file.'">'.$file.'</a></li>';
}
?>
Are you saying that does not output anything? Are you running this from CLI (to test with) or from the server? Try running it the other way to see if there's a difference.

 

And I'll say it again because 99% it's the cause of this problem: the \\DERFPFNAP001\all.rb share and the all.rb\Vorlagen file permissions are definitely allowing your IIS to connect? As in when you check the permissions you see an entry for IUSR or IUSR_something*, and that entry grants read and list permissions?

 

Also, I tend to assume people have their PHP error settings set to something useful, but that's not always the case. Do you have

error_reporting = -1
display_errors = on
in your php.ini? If not, set them, restart the IIS application pool, and see if there are any errors or warnings on that one page.

 

* I think it's IUSR_machine_name. Others groups may work too, like Everyone or Authenticated Users.

Edited by requinix

It works now, thanks. 

 

Because the company i work for is part of a bigger one, the headquarter has all the IUSR'S.

I added a administration User in the IIS and now it works.

 

The only thing left is to make the files downloadable ^^

 

Thanks fpr your help :) 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.