简体   繁体   English

仅从特定文件夹上传

[英]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.

相关问题 仅从特定文件夹或URL浏览 - Browse from specific folder or url only 使用javascript,xhtml或Flash从客户端计算机上的特定文件夹上载文件? - javascript, xhtml, or flash to upload a file FROM a specific folder on a client machine? 上传到谷歌脚本中的特定文件夹 - Upload to a specific folder in google script 如何将文件上传到 Backblaze 上的特定文件夹? - How to upload file into a specific folder on Backblaze? 上传到特定文件夹 Firebase Storage NodeJS? - Upload into specific folder Firebase Storage NodeJS? 如何删除警告“这将从 [文件夹] 上传所有文件。仅当您信任此站点时才执行此操作。” - how to remove the warning "This will upload all files from [Folder]. Only do this if you trust this site." 仅以特定格式上传文件的条件 - a condition for upload file only with specific format 限制 Dropzone 仅上传特定类型的文件 - Restrict Dropzone to upload only specific type of files 我想在文件上传按钮上打开一个特定的文件夹 - I want to open a specific folder on file upload button 无法使用文件上传将图像上传到 node.js 中的特定文件夹 - Unable to upload images to a specific folder in node.js using fileuploads
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM