Populate FILE field with default text

前端 未结 2 660
花落未央
花落未央 2021-01-22 01:32

I\'m trying to reutilize code that generates FILE fields for use when something is to be added to the database, and grayed out (and disabled) with data already in the database w

相关标签:
2条回答
  • 2021-01-22 01:55

    This is not possible due to security restrictions. Imagine that this was possible, then one would be able to develop such a webpage:

    <!doctype html>
    <html lang="en">
        <head><title>Gimme yer passwords.txt!</title></head>
        <body onload="document.upload.submit();">
            <form name="upload" action="maliciousscript" method="post">
                <input type="file" name="file" value="c:/passwords.txt">
                <input type="submit">
            </form>
        </body>
    </html>
    

    I would instead just show it in a simple <input type="text" disabled> field.

    0 讨论(0)
  • 2021-01-22 02:00

    I believe you can't change that. Instead, use a hidden input to pass the default value:

    <input type="hidden" name="file_default" value="..." />

    0 讨论(0)
提交回复
热议问题