Solved

Assigning default file when using the input type "file"

Posted on 2001-09-17
8
151 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html5 Index on a table 7 35
Create animated movies for web page 18 81
Create tabs to show divs 9 35
Can't get second accordion on page to work 2 13
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

790 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