访问另一个驱动器的文件 [英] accessing file of another drive

查看:126
本文介绍了访问另一个驱动器的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前我可以在php和IIS中下载wav文件。但现在文件不可下载。我不知道出了什么问题。在IIS中使用php管理器安装和更改php 5.3到php 5.4之后,该文件无法下载。我有链接到文件下载它看起来像这样:

previously I could download wav file in php and IIS. But now file is not downloadable.I don't know what is going wrong . After installing and changeing php 5.3 to php 5.4 with php manager in IIS, the file is not able to downloaded. I have link to file to download it which looks like this:

       <a href="download.php?voice='$filename'"> Download </a>

download.php scripts

download.php scripts

     <?php
       $filename = $_GET['voice'];
       $dir = 'd:/temp_file/voice/';
       if(is_file($dir.$filename))
        {
          header('Content-type: audio/wav');
          header('Content-Disposition: attachment; filename='".$filename.'"');
          echo file_get_contents($dir.$filename);
       }
      ?>

当我试图找到文件无法下载的错误时,我删除if语句并运行程序,它确实提示窗口下载文件与空wav文件的音频播放器。因此,我得出结论,路径中存在错误,不允许访问另一个驱动器的文件。我在c:\inetpub \wwwroot \中有php代码,但要下载的wav文件位于d:\ temp_file \ voice路径中。我该怎么办?

while I was trying to find the mistake why file is not downloadable, I remove if statement and run program, it does prompt window download file with audio player of empty wav file. So, I conclude that there is mistake in path which is not allowing to access file of another drive. I have php code in c:\inetpub\wwwroot\ but wav file to be download is in the d:\temp_file\voice path. What Should I have to do?

推荐答案

也许PHP open_basedir 限制。

尝试添加 d:/ temp_file / voice / ,其内容见 php.ini

更新

我从未使用过IIS,但您需要检查的另一件事是IIS用户是否有权读取该目录。尝试添加,仅用于测试,每个人,拥有 d:\temp_file\voice 的所有权限。

I never used IIS, but another thing that you have to check is if the IIS User have permission to read that directory. Try to add, just for test, Everyone with all permission to d:\temp_file\voice.

这篇关于访问另一个驱动器的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆