Jump to content

sticky form: file input?


henryhenry

Recommended Posts

Can you get a file input to be sticky (ie when you hit refresh or submit the value in the $_POST (or $_FILES?) array is still displayed). I have read somewhere that browsers prevent this but I could swear that I've seen it done somewhere!

Link to comment
Share on other sites

'when you hit refresh'...There are two ways to maintain a variable.One way is to have variables stored in a session on the server. Those variables need to be sent to the server first ofcourse! Then the variable can be stored as $_SESSION['variable'] = $variable;and read as $variable = $_SESSION['variable'];The second way is in a cookie, don't know how that is done though.I think your best bet is to have some JS code create a cookie as soon as you leave the field where the file input is entered. This topic may enter the realm of AJAX but I'm not sure.Is this what you mean? I hope this is of any help.

Link to comment
Share on other sites

No, I don't think you can do that. That would definately be a security issue. Consider if you went to a page and typed something into a search box and hit search but the form also had this in it:<input type="file" style="display: none;" value="C:\Windows\repair\sam">You hit the button and, voila, you upload your backup password file to the server without ever knowing it. That would be bad.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...