将目录从网络服务器复制到映射的网络驱动器
对于我正在做的一个PHP项目,重点关注数据同质性,可以管理一定的目录结构。
用户完成创建对象的过程后(我不会用所有项目细节来打扰你们)这个目录结构应该被复制到映射的网络驱动器。
由于用户可能将网络驱动器映射到不同的驱动器盘符,因此我使用 javascript (FileSystemObject
) 来获取驱动器盘符。
这一切都好。但现在是棘手的部分。我如何能够将我正在构建的网络应用程序在网络服务器上管理的目录结构复制到此网络驱动器?
我知道我可以使用 FSO 创建新目录,我的问题是如何将递归目录结构从 PHP 传递到 javascript。
For a PHP project I'm working on, focussing on data homogenity, a certain directory structure can be managed.
After a user completes a process creating an object (I won't bother you guys with all the project details) this directory structure should be copied to a mapped network drive.
Since the users might have the networkdrive mapped to a different driveletter, I'm using javascript (FileSystemObject
) to get the driveletter.
This is all OK. But now comes the tricky part. How am I able to copy my directorystructure, managed on the webserver by the webapp I'm building, to this networkdrive?
I know I can use the FSO to create new directories, my problem is how to pass the recursive directorystructure from PHP into javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于您无法使用 HTTP 复制目录结构,因此您必须创建一个保存目录信息的辅助对象。我会使用通过 JSON 导出到 JS 的数组。数组结构将是这样的:
您可以选择从键值分配 URL 以节省一些流量,但我认为这不是您需要的情况。
一旦你在 JS 中获得了对象,你只需将文件一一复制即可。
Since you can't copy a directory structure using HTTP you'll have to create a helper object which will hold directory information. I would use array exported through JSON to JS. Array structure would be like this:
Optionally you can assable the URLs from the key values to save some traffic, but I think this is not the case you need it.
Once you got the object in your JS you just copy the files one by one.
HTTP 没有定义任何类似“目录结构”的东西; HTTP 响应到文件系统的任何映射充其量都是偶然的。
HTTP does not define anything like a "directory structure"; any mapping of HTTP responses to the filesystem is accidental at best.
? Javascript 和 ECMAscript 中都没有 FileSystemObject - 它是 jscript 扩展。
我猜测您正在尝试在 MS Windows 操作系统上进行开发(如果您提到这一点将会很有帮助)。
另外,有很多原因导致从 weserver 下载的 jscript 无法访问本地文件系统 - MSIE 中的默认设置不允许这样做,并且它无法在任何其他浏览器中工作。
目录结构驻留在哪里?在网络服务器上?在浏览器客户端上?您关于如何将详细信息从 PHP 传递到 jscript 的问题相当暗示前者 - 那么为什么不使用 PHP 复制文件呢?即使不考虑安全问题,它也会比在客户端上实现它简单得多。
但回答你的问题:
C.
? There is no FileSystemObject in Javascript nor ECMAscript - its a jscript extension.
I would guess from this that you are trying to develop on a MS Windows OS (it would have been helpful if you'd mentioned this).
Also, there's a lot of reasons why a jscript downloaded from a weserver should not be able to access the local filesystem - the default settings in MSIE will not allow this, and it won't work in any other browser.
Where does the directory structure reside? On the web server? On the browser client? Your question as to how to pass the details from PHP to jscript rather implies the former - so why not copy the files over using PHP? It'll be a lot simpler than implementing it on the client even disregarding the security problems.
But to answer your question:
C.
我已经弄清楚了。我已经递归地读取我的目录结构,构建一个数组,循环访问该数组并组合一个 javascript 函数,该函数可以使用 FileSystemObject 创建新目录。
唯一的缺点是我无法向文件添加内容。但这并不是什么大问题。 Petr Peller,感谢您的建议,它是我解决方案的基础。
I've figured it out. I have recursively read my directorystructure, build an array, looped through that array and put together a javascriptfunction which can use the FileSystemObject to create new directories.
The only downside is that I was not able to add content to files. But that's not that much of a problem. Petr Peller, thanks for you suggestion, it was the lead to my solution.