PHP upload/read files on separate drive

ε祈祈猫儿з 提交于 2019-12-04 06:24:37

问题


I need to be able to upload/view files on a separate drive.

Right now, my site is in the htdocs folder on the C: drive. We have been allocated space on the D: drive to upload and view files.

Using the code below, I can use scandir to view what is located in htdocs folder:

<?php
 $dir    = '../../htdocs/';
 $files1 = scandir($dir);
 $files2 = scandir($dir, 1);

 print_r($files1);
 print_r($files2);
?>

But I need to traverse back a few more to be able to get to the D: drive. I am not sure if this is even possible.

Using the above code, when I attempt to traverse to the D: drive, the path would look something like this:

$dir    = '../../../D:/uploadFiles/';

I am not sure if that is the correct format when going back and viewing something in the D: drive. I guess if it was, I would be seeing something on the screen, which I am not.

Upon conducting my research online, the closest thing that I could find was this post:

upload file on drive d:// php

But I need to be able to first read the files in the folder on the D: drive.

Is what I am trying to do possible using PHP? If it is, how can I fix my path so that I can see the files in the uploadFiles folder on the D: drive?


回答1:


All Directory Functions.

Simple as:

scandir('C:/some/path/uploadFiles');
scandir('D:/some/path/www/htdocs');

Or whatever... Write out the full paths. Don't even do that ../../ stuff. Relative paths / absolute paths. I think you are overcomplicating things.



来源:https://stackoverflow.com/questions/51142542/php-upload-read-files-on-separate-drive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!