Set file name in input file dialog

Asked

Viewed 327 times

2

Good morning, I wonder if there is any way to set a default name in the dialog input type="file".... And there is also how to define the path in which this dialog will open. Ex.: "/Downloads/", (I’d like you to always lead the way).

IMAGE:

inserir a descrição da imagem aqui

JSFIDDLE:

http://jsfiddle.net/2s39c2y9/

2 answers

3

So far, for security reasons it is not possible to set the folder in which the input file will open nor the predefined file name.

This is done by security measure to prevent the user from submitting some file without realizing it.

Who needs things of the kind has to turn to java widgets, which makes the process heavier and bureaucratic.

  • 1

    And in C# you know some way?

  • 2

    In C already escapes from my knowledge, that deserves another question ;)

  • Yes, in C# it is possible yes. Post in another question we will say how!

3


After a query of the HTML documentation, I confirmed that you do not have an option to define where the dialog will open.

What you can define is the type of files that will be accepted with Accept:

Accept
If the value of the type attribute is file, this attribute indicates the types of files that the server accepts; otherwise it is Ignored. The value must be a comma-separated list of Unique content type specifiers: A file Extension Starting with the STOP Character (U+002E). (E.g.: ". jpg,. png,. doc")
A Valid MIME type with no Extensions
audio/* Representing sound files HTML5
video/* Representing video files HTML5
image/* Representing image files HTML5

Source: HTML documentation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.