Page 1 of 1
Cannot echo value in file field
Posted: Fri Nov 25, 2005 5:16 am
by thomas777neo
I cant seem to show an initial value in a file field:
Code: Select all
<input name="example" type="file" id="example" value="thomas" />
Is there anyway around it?
Posted: Fri Nov 25, 2005 5:33 am
by Skittlewidth
Unfortunately most browsers don't support prepopulating the value of a file input field. I think its for security reasons.
Posted: Fri Nov 25, 2005 5:37 am
by malcolmboston
Skittlewidth wrote:Unfortunately most browsers don't support prepopulating the value of a file input field. I think its for security reasons.
since when? ive been doing this for years now, never noticed any problems
Posted: Fri Nov 25, 2005 5:39 am
by thomas777neo
That sucks, oh well
Posted: Fri Nov 25, 2005 5:45 am
by Skittlewidth
malcolmboston wrote:
since when? ive been doing this for years now, never noticed any problems
Really? How? I was trying to do it a few months back on an edit form and I couldn't get it to work. I googled the problem and other people said it couldn't be done.
I ended up having to echo to the user what their previous attached file was above the file input field instead.
Posted: Fri Nov 25, 2005 5:45 am
by shiznatix
what browser are you testing this on?
Re: Cannot echo value in file field
Posted: Fri Nov 25, 2005 7:14 am
by malcolmboston
well i would just do something like:
Code: Select all
<input name="example" type="file" id="example" value="<?php print $value; ?>">
i know for a certainty this works on at least the following on my home computer:
IE 5.5
IE 6
Firefox (god knows what version)
Opera 7
Opera 8
Mozilla (Unknown)
all versions are relatively new
Re: Cannot echo value in file field
Posted: Fri Nov 25, 2005 7:19 am
by foobar
malcolmboston wrote:well i would just do something like:
Code: Select all
<input name="example" type="file" id="example" value="<?php print $value; ?>">
i know for a certainty this works on at least the following on my home computer:
IE 5.5
IE 6
Firefox (god knows what version)
Opera 7
Opera 8
Mozilla (Unknown)
all versions are relatively new
That's odd. That's a huge security issue. You could upload the user's users.dat or system.dat that way (or anything else for that matter)!
/goes and tries to do it
Posted: Fri Nov 25, 2005 7:24 am
by malcolmboston
lol, just noticed this is an file input box, have never tried it with one of them

Posted: Fri Nov 25, 2005 7:29 am
by foobar
malcolmboston wrote:lol, just noticed this is an file input box, have never tried it with one of them

YOU.....!

Posted: Fri Nov 25, 2005 7:30 am
by malcolmboston
pmsl

Posted: Fri Nov 25, 2005 7:33 am
by Skittlewidth
Phew! You had my confidence shaken there for a bit!
Posted: Fri Nov 25, 2005 7:55 am
by n00b Saibot
had me miffed too
