Solved

Assigning default file when using the input type "file"

Posted on 2001-09-17
8
150 Views
Last Modified: 2011-09-20
Hi I am using a file dialog to select an image and I want to set or assign in the text box the default filename what I wrote is:
<INPUT TYPE="FILE" NAME="fileImage" title="Browse Image" value="Default.gif">Image</INPUT>

but using the value="Default.gif" doesnt put the text default.gif in the text box of the component.
Can anyone tell me how I can place the default file name on the text box of the file component. You know when using the file component you have a text box and a browse button. I want to put the default filename in the text box.

Thanks in advance.
0
Comment
Question by:denz_1
8 Comments
 
LVL 1

Expert Comment

by:FranzRinkleff
ID: 6487923
to begin with your input statement should look like this.  you forgot the accept attribute.

<input type="file" name="fileImage" title="Browse Image" accept="image.gif">
0
 
LVL 1

Accepted Solution

by:
FranzRinkleff earned 50 total points
ID: 6487925
i meant like this

<input type="file" name="fileImage" title="Browse Image" accept="image/gif">
0
 

Author Comment

by:denz_1
ID: 6488150
but I also want to accept jpeg, and still doesnt answer my question. how do I specify the default file.. such as default.gif or filename.gif
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6488244
You cannot specify a value for this type of input.  It would be a huge
security hole.  the accept attribute being suggested by Franz is in the
HTML standard but is not supported by any browser because it would allow
a web site to steal files from a users computer.

If you want to limit the files to specific types, I can give you code
to do that kind of filtering, but you cannot force a value into this
type of input.

Cd&
0
 
LVL 1

Expert Comment

by:FranzRinkleff
ID: 6488396
cobolDinosaur
I was not aware it was not supported by any browser.  I do something similiar with Cold Fusion and it prevents someone from uploading documents of the wrong type (at least that is what I think it is doing).

I am confused at how the browsers supporting this HTML standard would allow a web site to steal files from a users computer?  Please explain.  

Thanks, Franz
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6488458
Pretty obvious when you think about it...

If you can specify what file to upload, you can grab every setting on their computer, passwords files, etc. I could grab your mailbox file (there's only a few names/places for them), which would conceivably have all your addresses, e-mail accounts, and any usernames/passwords for sites you've signed up for -- and that's just for starters.

You'd never know. YOU wouldn't pick the file, you probably wouldn't even see the upload happen.

That's why it's a HUGE security hole and why no browser supports it.
 
0
 
LVL 1

Expert Comment

by:FranzRinkleff
ID: 6488470
the accept attribute specifies the TYPE of file to upload NOT the file to upload.  How would this present a security hole?  

I understand why having a default file name to upload would be a problem.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6488596
Franz,

Sorry, I was trying to combine too many thoughts in one
sentence.  The accept attribute is not supported was thought 1.
The accept attribute still would not do what they want which is
set a default, was thought 2.  Being able to set a default would
allow the theft of files was thought 3.

All of which got scrambled together, and ended up somewhat
incoherent dinosaur babble.  

Cd&
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question