[英]Upload from specific folder only
I have my working upload button that is used to browse an image from any folder and then decode the image 我有一个正常工作的上传按钮 ,用于从任何文件夹浏览图像,然后对图像进行解码
Here is my code in js: 这是我在js中的代码:
var imghtml='<div id="qrfile"><canvas id="out-canvas" width="320" height="240"></canvas>'+
'<div id="imghelp">Select a QR'+
'<br>or drag & drop here'+
'<input type="file" onchange="handleFiles(this.files)"/>'+
'</div>'+
'</div>';
And here is the function handleFiles: 这是功能handleFiles:
function handleFiles(f)
{
var o=[];
for(var i =0;i<f.length;i++)
{
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
canx.clearRect(0, 0, bCanvas.width, bCanvas.height);
qrcode.decode(e.target.result);
};
})(f[i]);
reader.readAsDataURL(f[i]);
}
}
I dont want user to browse all folder but rather one specific folder, defined by me, where all image will be store ( am currently using localhost but will move it to web server afterward). 我不希望用户浏览所有文件夹,而是浏览由我定义的一个特定文件夹,所有图像都将存储在其中(当前正在使用localhost,但之后将其移至Web服务器)。 anyone can help please?
有人可以帮忙吗?
This can't be done because of security reasons. 由于安全原因,无法执行此操作。 You have no option to do this.
您别无选择。 If you would be able to, users might accidentally upload files that are not meant to be uploaded (bank account information).
如果可能的话,用户可能会意外上传不需要上传的文件(银行帐户信息)。
You might want to consider persuing the possibility to upload multple files in one upload prompt dialog. 您可能要考虑说服在一个上传提示对话框中上传多个文件的可能性。 That way you at least don't have to do every file individually ;)
这样,您至少不必单独处理每个文件;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.