简体   繁体   中英

Checking if file exist in html/javascript

I need to have password protected website without password, i have a dream then the website will check "does your computer containt file acess.txt ,if this file contains 123456,website do ok you have an acess and redirects you to index.html

I hosting my website in Node.js And i also running on Linux Debian

Apologie for my English, im Czech and young . and yes im a programmer.

does your computer containt file acess.txt,if this file contains 123456,website do ok you have an acess

You can't do that without having the user manually pick that file from an input type="file" or drag-and-drop it into your web page. For security reasons, web pages cannot check for files they provide the path of.

and redirects you to index.html

That would mean your site is completely insecure anyway — anyone could just go directly to index.html .

All access checks must happen on the server , not the client (browser).

Simple!

Replace:

<input name="post_password" type="password" value="" />

With:

<input name="post_file" type="file" value="" />

However you can not have JavaScript go snooping through a person's file system. They must choose to browser and select a file to upload and then submit the form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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