How to add a description to input file accept in HTML? - html

Example: https://codepen.io/anon/pen/KyBKLK
HTML:
<input type="file" accept=".test">
The file dialog shows only files with the .test extension. However, often file dialogs show an accompanying description of the file type, like "Test file (*.test)". Is it possible to add such a description to the file extension?
Here are a couple of examples: In MS Word one will get "Word-Documents (*.docx)" in the filter drop down. In a browser, for example, "XML Files (*.xml)". Similarly, I would like to have the drop down show "Test file (*.test)", or similar. But the code above will show only "*.bec" in the file extension filter.

Related

show the file names and allow user to remove the files before submitting the form [duplicate]

This question already has an answer here:
How to POST binary files with AngularJS (with upload DEMO)
(1 answer)
Closed 4 years ago.
I am working on a web page where user need to upload files and send them along with some message..
First thing i noticed is when we want to upload a file or send an attachment(single or multiple) we need to use below line of code:
<input type = "file" name="file" file-model="file" multiple/>
With the above code when user is selecting more than one file it is not showing the file names on the webpage instead showing 2 files if 2 files are selected. I want to show the file names and user should able to delete the file before sending if he likes to remove it before submitting the form(just like we do in email attachments).
sample plunker : https://plnkr.co/edit/Le6edwhX3Bye6E2XwIhd?p=preview
Any inputs on how to do it using angularjs.
I would recommend using BlueImp Angular File Uploader: https://blueimp.github.io/ It would allow you to do this along with other cool things like drag and drop and ajax uploading
Here's a demo:
https://blueimp.github.io/jQuery-File-Upload/
Also, it looks like there's an Angular JS flavor of it:
https://blueimp.github.io/jQuery-File-Upload/angularjs.html

Adapt html5 file uploader to use known file URL instead?

I am trying to adapt an html5 file uploader (from tutorial) so it can submit an image URL (already held in a javascript variable) instead of asking the user to browse for a local file.
I believe the relevant code to adapt (but I might be wrong) is:
<input type="file" name="image_file" id="image_file" onclick="" onchange="fileSelectHandler()" />
Taken from tutorial: http://www.script-tutorials.com/html5-image-uploader-with-jcrop/
My end process will be:
Browse facebook albums and obtain gallery image to javascript variable (jquery.getfacebookalbums.js) - PASS (I can already Alert the URL of chosen file)
Adapt the HTML5 file uploader as used in the tutorial, to push the stored facebook image URL instead of a file. (And it would be ideal to be able to do this without redundant button clicks, since file url is already present to input)
Many thanks!
UPDATE:
My attempts at a starting point to achieve this have failed.
In my main html page I have a javascript variable storing full path to .jpg
The original post sequence was:
(html file)
(.js file)
function fileSelectHandler() {
// get selected file
var oFile = $('#image_file')[0].files[0];
...
And variations I've tried to post a stored javascript variable .jpg URL are:
(html file javascript)
alert("image_file is" + image_file);
fileSelectHandler();
or
<form action="fileSelectHandler()">
URL: <input type="text" name="image_file" id="image_file" value="splashScreen.jpg">
<input type="submit" value="Submit form">
</form>
As starting points.
...And I would like to be able to Alert from the fileSelectHandler() in the .js file as to what value it has received for: var oFile = $('#image_file')[0].files[0]; so I can more easily understand what is being passed - but alert(oFile) or alert($('#image_file')) is being ignored.
Thanks in advance!

Set file path for input type="file"

Can we set the file path in javascript for
<input name="pictureUL" type="file" value="upload" onChange="this.form.submit()"/>
without opening the select file dialog box?
I have 2 buttons SCAN and FIND. ADD button opens dialog box asking user to select the file which will be uploaded to the server. SCAN button has to scan the document and upload it to the server. Scanning is fine but to submit the form i need to set the file path in the file tag as i am submitting the form there. Is there a way to do it?
Thanks in advance.
Due to possibly security issues, modern browsers do not allow you to access the file path or modify the value of an <input type="file">. You also cannot view the file path, as it will display C:\fakepath\yourfilename.yourfilextension.
You can't do it directly but you can create your new Filelist using a DataTransfer object, and if you wish you can copy your data into it to and create a duplicate with the specific change you want to make.
let file = new File([blob], fileName);
let list = new DataTransfer();
list.items.add(file);
You can then set it as the file attribute of the DOM node:
fileInput.files = myFileList;

How to create links to sections in pdf

Can we create a hyperlink or an embed tag that will display a specified page/section of a PDF document?
let me know if anybody has any idea
ex:
Open PDF using subsection
I know appending #page=X works, but I've now had some luck appending #subsection.X.Y. For example: http://tug.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf#subsection.14.1
Just to go to an existing PDF file page you can use
#page=pageNumber
PDF parameter.
Yes it seems to be possible, please see this link http://www.pdfobject.com/examples/index.php and http://www.pdfobject.com/ for more information. This is from the site "PDFObject is an easy-to-use method for dynamically embedding PDF files into HTML documents. It uses JavaScript to generate and inject a standards-friendly "
<script type="text/javascript">
window.onload = function (){
var success = new PDFObject({ url: "http://www.adobe.com/content/dam/Adobe
/en/devnet/acrobat/pdfs/pdf_open_parameters_v9.pdf#page=6&zoom=150,0,216"
}).embed("pdf");
};
</script>
As you can see you can change the URL link to
thefile.pdf#page=YOURDESIREDPAGE
Linking to a destination within PDF in a webpage as found on this page,
Citation start:
"
Linking to a destination is essentially the same principle but involves a few more
steps
and setting up. First up, you'll need to create the destination.
Creating a destination in a PDF using Adobe Acrobat:
Manually navigate through the PDF for the desired location, and magnification.
Move your curser to the right of the PDF, in the navigation pane.
Right click and select destination. This will open the Destinations pane.
Right click, select New Destination enter an appropriate name and select the area that
you want the destination to link to.
NOTE: Make sure that the name does not have any spaces as it makes it easier to link to
afterwards.
You are now ready to link to the destination using a similar syntax as linking to a
specific page, instead of #page write #nameddest.
Append "#nameddest=" and the name of your chosen destination. So, if your PDF has a
named destination, "TOC", that points to a table of contents, then your link code will
look like this:
Link Text
"

using VW7.8/Jun789 JunFileDialog for file save and want to remember selected directory for next time

I am using VW7.8/Jun789 JunFileDialog for a file save as and want to remember/set the selected directory for next time. I am following JunFileDialog class example5. I suppose doing so in the onAccept: block should be possible, but so far I've had no success.
I'm having trouble understanding where or how to set the initialDirectory other than as per the example in the JunFileDialog>>request: messageString initialDirectory: directoryFilename initialFile: filenameString fileTypeMenu: aMenu initialFileType: fileType onAccept: acceptBlock onCancel: cancelBlock.
Is there a better file save dialog to use?
you can use VisualWorks' Dialog class. On class side it has the "file name dialogs" protocol. There you can find methods like #requestFileName:default: or #requestNewFileName:default:. Both should display a native dialog on Windows and Mac OS X which defaults to the last opened folder.