Solved

Assigning default file when using the input type "file"

Posted on 2001-09-17
8
147 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
Comment Utility
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
Comment Utility
i meant like this

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

Author Comment

by:denz_1
Comment Utility
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:FranzRinkleff
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now