PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Fri Nov 25, 2005 5:16 am
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?
Skittlewidth
Forum Contributor
Posts: 389 Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK
Post
by Skittlewidth » Fri Nov 25, 2005 5:33 am
Unfortunately most browsers don't support prepopulating the value of a file input field. I think its for security reasons.
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Fri Nov 25, 2005 5:37 am
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
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Fri Nov 25, 2005 5:39 am
That sucks, oh well
Skittlewidth
Forum Contributor
Posts: 389 Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK
Post
by Skittlewidth » Fri Nov 25, 2005 5:45 am
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.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Fri Nov 25, 2005 5:45 am
what browser are you testing this on?
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Fri Nov 25, 2005 7:14 am
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
foobar
Forum Regular
Posts: 613 Joined: Wed Sep 28, 2005 10:08 am
Post
by foobar » Fri Nov 25, 2005 7:19 am
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
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Fri Nov 25, 2005 7:24 am
lol, just noticed this is an file input box, have never tried it with one of them
foobar
Forum Regular
Posts: 613 Joined: Wed Sep 28, 2005 10:08 am
Post
by foobar » Fri Nov 25, 2005 7:29 am
malcolmboston wrote: lol, just noticed this is an file input box, have never tried it with one of them
YOU.....!
Skittlewidth
Forum Contributor
Posts: 389 Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK
Post
by Skittlewidth » Fri Nov 25, 2005 7:33 am
Phew! You had my confidence shaken there for a bit!
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Fri Nov 25, 2005 7:55 am
had me miffed too