[英]How can I send a text file to all open browsers on a website when a user submits a PHP form
[英]how can i open a text file from php using fileselector
我想使用html中的文件选择器在php中打开文本文件
这是我的HTML代码
<form>
<select>
<option value="">Select a source</option>
<option value="NOTEPAD">NOTEPAD</option>
<option value="XML">XML</option>
<br>
<input type="file" name="datafile" id="fileid" size="40">
<br>
<input type="button" value="Read Source" onclick="showRSS('test')"></input>
</select>
</form>
我试图从ID="fileid"
获取路径并将其发送到php
var num;
num="xyz";
var loc;
var loc = document.getElementById("fileid").value;
xmlhttp.open("GET","read.phpq="+encodeURIComponent(num)+"&x="+encodeURIComponent(loc),true);
xmlhttp.send();
我的PHP代码是:
$lc=$_GET['x'];
$i=$_GET['q'];
$myfile = fopen($lc, "r") or die("Unable to open file!");
但是我的文件路径显示为C:\\ fakepath \\ try.txt,我如何发送正确的路径到我的PHP脚本。
在要保存的服务器上尝试temp_name。
您必须首先将文件上传到服务器。 如果您在选择文件时想要这个东西,请使用jquery文件上载器而不是fileselector控件。 因为Jquery文件上传器将直接在给定路径上将文件上传到服务器上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.