logo
down
shadow

Threepenny-gui: get file path via 'file' input


Threepenny-gui: get file path via 'file' input

By : Alexandra Dra
Date : November 19 2020, 03:01 PM
seems to work fine As far as I know, web browsers do not allow you to obtain a filepath via the fields, for reasons of security. You can only obtain the file contents. Of course, you can always ask for a filepath in a plaintext input field, but that is certainly less convenient for the user.
Filepaths can be obtained from a file chooser dialog if you combine Threepenny with the Electron framework. Working with files is one of the reasons for using Electron.
code :


Share : facebook icon twitter icon
How to reload updated file in Threepenny-gui 0.6?

How to reload updated file in Threepenny-gui 0.6?


By : user3646714
Date : March 29 2020, 07:55 AM
it helps some times (Author here.) Apparently, I didn't consider your use case when removing these functions. :-) I can add them back in if you like, could make an issue on github?
There are various methods on the JavaScript side to reload a file at a certain URL. See for instance the question "Refresh image with a new one at the same url".
How to get selected file name and file path from input type file using jQuery

How to get selected file name and file path from input type file using jQuery


By : Ece T.
Date : March 29 2020, 07:55 AM
may help you . https://developer.mozilla.org/en-US/docs/Web/API/File/name
Returns the name of the file represented by a File object. For security reasons, the path is excluded from this property.
Getting input path and file, output path and file from command line argument in Python

Getting input path and file, output path and file from command line argument in Python


By : Rajkumar
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I am trying to make my little python script run by this command:
code :
python ./pdweb_convert.py -i /path_to_file/input_file_name -o /path_to_file/output_file_name
C:\Users\Desktop>python x.py -i /path_to_file/input_file_name -o /path_to_file/output_file_name
Traceback (most recent call last):
  File "x.py", line 4, in <module>
    with open(inputfile, 'r') as i, open(outputfile, 'w') as o:
FileNotFoundError: [Errno 2] No such file or directory: '-i'
File upload with text input field so user can enter file path too

File upload with text input field so user can enter file path too


By : user3384893
Date : March 29 2020, 07:55 AM
it fixes the issue You can do this by using a hidden input of type='file', together with a button and an input of type='text'. To make the button active we add a trigger at the onclick of the button. onchange of the input type='file' we trigger a function changeInput to change the content of the input type='text'.
Which results in the following html:
code :
<input type="text" id="filename" name="filename"><button onclick="document.getElementById('file').click();">Open</button>
<input id="file" type="file" name="file" style="display: none;" onchange="changeInput()" />
<script>
function changeInput(){
  document.getElementById("filename").value = document.getElementById('file').value;
}
</script>
<input type='file'> always searches the input file in the path of the HTML file itself

<input type='file'> always searches the input file in the path of the HTML file itself


By : Gato
Date : March 29 2020, 07:55 AM
it helps some times Let's say I have a HTML file named site.html. The full path name of this file is C:\Users\Anton\Documents\Projects\site.html. , You might want to do something like:
code :
//<![CDATA[
/* js/external.js */
var doc, html, bod, nav, mobile, M, I, S, Q, aC, rC; // for use on other loads
addEventListener('load', function(){
doc = document; html = doc.documentElement; bod = doc.body;  nav = navigator;
mobile = nav.userAgent.match(/Mobi/i) ? true : false;
M = function(tag){
  return doc.createElement(tag);
}
I = function(id){
  return doc.getElementById(id);
}
S = function(selector, within){
  var w = within || doc;
  return w.querySelector(selector);
}
Q = function(selector, within){
  var w = within || doc;
  return w.querySelectorAll(selector);
}
aC = function(element, className, yFunc){
  var s = element.className.split(/\s+/), n = s.indexOf(className);
  if(n === -1){
    s.push(className); element.className = s.join(' ').trim();
    if(yFunc)yFunc(element);
  }
  return function(className, yFunc){
    return aC(element, className, yFunc);
  }
}
rC = function(element, className, yFunc){
  var s = element.className.split(/\s+/), n = s.indexOf(className);
  if(n !== -1){
    s.splice(n, 1); element.className = s.join(' ').trim();
    if(yFunc)yFunc(element);
  }
  return function(className, yFunc){
    return rC(element, className, yFunc);
  }
}
// above is a mini-library - below could be on another page if you want - except the load end
var out = I('output');
I('upload').onchange = function(){
  if(this.files.length){
    var file = this.files[0], img; // first file
    if(this.value.match(/\.(png|jpe?g|gif)$/i)){ // file.type is unreliable
      out.innerHTML = ''; rC(out, 'error'); img = M('img');
      img.src = URL.createObjectURL(file); out.appendChild(img);
    }
    else{
      aC(out, 'error'); out.innerHTML = 'Must Be An Image';
    }
  }
}
}); // end load
//]]>
/* css/external.css */
*{
  box-sizing:border-box; padding:0; margin:0;
}
html,body{
  width:100%; height:100%;
}
body{
  background:#ccc;
}
.main{
  padding:5px 7px;
}
.error{
  color:#900;
}
.hide{
  display:none;
}
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
  <head>
    <meta charset='UTF-8' /><meta name='viewport' content='width=device-width, height=device-height, initial-scale:1' />
    <title>Test Template</title>
    <link type='text/css' rel='stylesheet' href='css/external.css' />
    <script src='js/external.js'></script>
  </head>
<body>
  <div class='main'>
    <input id='upload' type='file' />
    <div id='output'></div>
  </div>
</body>
</html>
Related Posts Related Posts :
  • Can Haskell's Opaleye DSL generate any given SQL?
  • How can I return a list from list of list Haskell
  • Making Monad type showable
  • The usage of monad transformers
  • How to create a generic Complex type in haskell?
  • EAN13 Barcode Encoding in Haskell: How to test it?
  • How to implement the Arbitrary instance for data type like this?
  • How to use Parsers from Aeson with IO
  • Split a tuple into n parts
  • Xmonad - How do I move mouse pointer as part of ManageHook?
  • Idiomatic way to have many of the same generators in a list comprehension
  • Tree construction from a node string (Can't understand this Haskell code)
  • Give a default value for fields not available in json using aeson
  • grouping a list of lists by their first element
  • Reading Lines Asynchronously in Haskell
  • How do I enforce run-time conditions on data in Haskell?
  • Filtering by length of lines in file giving unexpected result
  • Sharing vs. non-sharing fixed-point combinator
  • What does "ignoring (possibly broken) abi-depends field for packages" mean?
  • What is "proxy a" in printtype function?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org