Filling FILE field with default text

I'm trying to reuse code that generates FILE fields for use when something needs to be added to the database and then highlighted (and disabled) by data already in the database when the item in question is edited or viewed in detail. However, I cannot get the text to fill the field. I am using this:

echo '<input type="file" name="small[]" value="' . $value_from_database . '" DISABLED><br>';

      

Did I miss something? If not, are there any suitable workarounds?

+2


a source to share


2 answers


This is not possible due to security restrictions. Imagine it was possible, then a web page like this could be created:

<!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>

      



Instead, I'll just show it in a simple box <input type="text" disabled>

.

+3


a source


I believe you cannot change this. Instead, use hidden input to pass the default value:



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

0


a source







All Articles