简体   繁体   English

如何将file_exist从服务器生成到本地机器?

[英]How to make a file_exist from a server to the local machine?

how to test if a file exist on the current computer using the application ? 如何使用应用程序测试当前计算机上是否存在文件?

I try to put the full url at my file like this, but it doesn't work : 我尝试将完整的url放在我的文件中,但这不起作用:

if(file_exists("C:/wamp/www/project/photo/".$nom_photo))
        {
            echo "file exist";
            $extension=pathinfo("C:/wamp/www/project/photo/".$nom_photo,PATHINFO_EXTENSION);
            echo "<br>";
            $nom=md5($nom_photo.time().rand(0, 99999)).".".$extension;
            echo $nom;
            rename("C:/wamp/www/project/photo/".$nom_photo,"C:/wamp/www/project/photo/".$nom);
            echo "<br>";


        }

How to fix it ? 怎么解决?

PHP operates server side and has NO ACCESS to the files on the machine running the web browser, unless they are indeed the same machine. PHP运行服务器端,并且无法访问运行Web浏览器的计算机上的文件,除非它们确实是同一台计算机。

If you are meaning to find a way to test if a file exists on the web server, the file_exists() function you mentioned should find it. 如果您想找到一种方法来测试Web服务器上是否存在文件,那么您提到的file_exists()函数应该可以找到它。 There are many reasons this might fail, including safe_mode , file permissions , and using the wrong path. 这可能会失败的原因有很多,包括safe_mode文件权限和使用错误的路径。

The server doesn't have any access to the clients filesystem, this would be a major security flaw. 服务器没有对客户端文件系统的任何访问权限,这将是一个主要的安全漏洞。

Also javascript is sandboxed so you couldn't do it on the client side either. 此外,javascript是沙盒,因此您无法在客户端执行此操作。

The only way I can think of doing this is to get the user to download a separate application that looks for the file and reports back to the server. 我能想到这样做的唯一方法是让用户下载一个单独的应用程序来查找该文件并将其报告回服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM