Is there any webextensions way to get a file picker which can get a file path and/or accept a directory as an argument? (like nsiFilePicker had previously)
Obviously this is for a native messaging add-on...
(And I'd prefer a built-in browser solution (or library) rather than having to implement a file picker HTML app myself communicating back and forth with Node for this purpose...)
You can use an <input type="file"> element:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
Related
I'm developing AngularJS app and I have file one-two-three-directive.js opened. I'd like to have/create a shortcut which will navigate to file one_two_three.html in the same project (dashes turn into underscores and there is no directive word).
Is there any way to achieve this (any existing plugin or other way will be appreciated).
Not currently possible out of the box, related ticket: https://youtrack.jetbrains.com/issue/IDEA-265643.
I'd suggest checking the Angular Component Folding - see if it works for you
I am looking for ways to find the Folder/Path details of the file selection in ReactJs,
I see all the examples concentrating on file selection only, I need to know the path details for my application.
you can't access to file path on the users' client for some privacy/security reasons, imagine this was possible, Then web apps could track users with this argument!
a NOTE about using ReactJs with ElectronJS: but if you work with ElectronJS you can do that by reading path of file object or use dialog API
I am new to the C# world and I want to know how can a Windows file upload form be automated using Selenium in a .Net core project as it doesn't support AutoIt.
Zehra - It really depends on how precise you want to get to mimicking the user functionality. Typically you click a button that opens a windows dialog where you locate the file on your pc/phone. Since this is really not testing the application and is just a Windows function, I just use send keys. If you want to get more precise, you can look at AutoIT but I would suggest just doing send keys.
Set your location for the file.
string filePath = #"C:\MyFiles\Test.jpg";
Then find the path to the input for the file upload.
driver.FindElement(By.XPath("//div[#class='FileUploadInput']")).SendKeys(filePath);
If you have a spinner or a bar for the upload process, I would wait until that element is no longer visible and then proceed.
As an example - go here - https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_get
In the example if you look at the "choose file" element, it looks like:
<input type="file" id="myFile">
You would then just do:
string filePath = #"C:\MyFiles\Test.jpg";
driver.FindElement(By.Id("myFile")).SendKeys(filePath);
Is there a way to upload a file by copying a file from the desktop and pasting it into a text input which will obviously just display the filename, rather than going through the file window and selecting the file?
Talking about web applications, that could be possible if you install a custom ActiveX object or even a Java applet, or maybe trying to exploit a browser vulnerability. But, most straight way to do that will be using a <input type='file'>
For client applications, you can do that, if your current user have appropriate permissions, like accessing your file system and accessing your web server through HTTP.
Anyways, you must provide more details to get more concrete answers.
I think this is not possible and should not be possible as this is a security issue. Consider the following scenario:
A malicious site example.com shows you a harmless looking form where they have hidden such a file upload textfield with the already inserted value '/etc/passwd'. They have used either a hidden_field or just display:none with CSS.
You fill in the form and submit without knowing you have also sent a file.
The only way I know to take the contents of a local file and push those bytes to a server is to set up a form post with an <input> of appropriate type to prompt the user to select a file.
I would like to do the same thing only pushing the data through XMLHttpRequest (no cross-scripting tricks).
Currently, we do this with an iframe to get the post behavior.
My sense is the iframe is the only solution, but I post here in case I've missed something.
You could use the JavaScript File API (available in Firefox 3.6 or later and latest versions of Chrome and Safari). Basically, you can add an event listener to the <input> tag that will fire when a user selects a file. Then, you can upload it using an XMLHttpRequest. Also, the File API can allow you to do other fancy stuff, such as drag-and-drop uploads, getting information about a file before it is sent to the server, and providing a progress bar as a file is uploading.More info: https://developer.mozilla.org/en/using_files_from_web_applications
This is not a good cross-browser solution because it doesn't have good support in all the popular browsers (Internet Explorer), but you could use feature detection in JavaScript to detect if the File API is available and revert back to your iframe method if it is not.