henryhenry Posted March 13, 2007 Share Posted March 13, 2007 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 More sharing options...
yoshida Posted March 13, 2007 Share Posted March 13, 2007 '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 More sharing options...
henryhenry Posted March 13, 2007 Author Share Posted March 13, 2007 HiSort of - maybe... I know how to get the normal form fields to retain their values but I can't make it work an upload field <input type="file" />. Can you use javascript to make this one maintain a variable? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 13, 2007 Share Posted March 13, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now