简体   繁体   English

如何在PHP中打开目标文件或文件夹

[英]How To Open Target File Or Folder In PHP

How to open a specific folder in file explorer using PHP, I already tried some code but it just directing to random folder. 如何使用PHP在文件资源管理器中打开特定的文件夹,我已经尝试了一些代码,但是它只是定向到随机文件夹。 Please help me. 请帮我。

I have try some code 我尝试了一些代码

if(empty($_POST['importdata'])) {
//Bahagian Kekotak Papar Button Import -mula-

echo '<form action = "" method="POST" name="upload_excel" enctype 
="multipart/form-data">';
echo '<fieldset>
<legend>Jadual Import Data Pelajar</legend>
<label>Pilih Fail (CSV) </label>
<input type ="file" name="file" id="file">
<input id="buttonon" type = "submit" name="importdata" value="UPLOAD & 
IMPORT"></fieldset>';

echo '</form>';
}else{
$filename=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"]>0) { //jika ada fail CSV
    //jika fail CSV telah dipilih
    $file = fopen($filename,"r");
    while (($getData = fgetcsv($file, 1000, ",")) !== FALSE)
    {
}

(this should be a comment, but its too long) (这应该是评论,但过长)

Reading the manual is always a good place to start. 阅读手册始终是一个不错的起点。

Allowing user direct access to write files on your webserver is inherently very dangerous. 本质上,允许用户直接访问您的Web服务器上的写入文件非常危险。 The way PHP implements file uploads mitigates many of the risks. PHP实现文件上传的方式可减轻许多风险。

How to open a specific folder in file explorer using PHP 如何使用PHP在文件资源管理器中打开特定文件夹

The sentence makes no sense. 这句话没有道理。

Files exist in folders, not the other way around. 文件存在于文件夹中,而不是相反。 Do you really want PHP to open up (Micorosf) File explorer showing the directory containing a nominated file? 您是否真的要PHP打开(Micorosf)文件浏览器,显示包含指定文件的目录? Do you mean to create a copy by "uploading" it from your client? 您是否要通过从客户端“上传”副本来创建副本? Your code example does not use nominated files / does not attempt to invoke other programs on the host. 您的代码示例不使用指定的文件/不尝试调用主机上的其他程序。

it just directing to random folder 它只是定向到随机文件夹

No. File uploads always go to the location nominated in your PHP.ini. 不能。文件上传总是转到您的PHP.ini中指定的位置。 If no directory is nominated, PHP puts the files in your system temp directory (as determined from your environment variables). 如果未指定任何目录,PHP会将文件放在系统临时目录中(由环境变量确定)。 And you can determine that location from dirname($_FILES["file"]["tmp_name"]) 您可以从dirname($_FILES["file"]["tmp_name"])确定该位置

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

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