44512

select a file without browsing using javascript

Question:

My main program prompts the user to browse for a file in order to convert it using ffmpeg. This is the format of the file browsing:

<div> <p class="lead">1. Select audio file for conversion ( mp3, wma):

<div class="quick-center"> <div class="quick-drop-outer quick-left"><input id="inFile" type="file" id="inputFile"/></div> </div> </div>

and this is the code where to launch the file and convert it according to selection: not whole code supported because no need of file conversion:

document.getElementById('inFile').addEventListener('change', handleFileSelect, false); function readInputFile(file) { // disable conversion for the time of file loading $('#convert').attr('disabled', 'true'); // load file content var reader = new FileReader(); reader.onload = function(e) { $('#convert').removeAttr('disabled'); fileName = file.name; fileBuffer = e.target.result; } reader.readAsArrayBuffer(file); } function handleFileSelect(event) { var files = event.target.files; // FileList object // files is a FileList of File objects. display first file name file = files[0]; console.log(file); if (file) { $("#drop").text("Drop file here"); readInputFile(file); } }

now, here is my problem, what I want to do is to upload the file directly from a selected folder (upload) where the audio files are already there. I want instead of browsing for the file, I want the last file in the upload folder to be uploaded instead of "inFile" so that conversion can happen. how could that happen. edit: A small brief about my project. the user records his voice using HTML5 and the link of that audio is uploaded using ajax and php into a folder named upload.what I simply want is instead of browsing that file, I want to write down the path of the file in the selected folder automatically once recording is done for conversion.so, instead of dropping the file by user, the file would be dropped and conversion starts from there. help please.Thank you in advance

Answer1:

From JavaScript You dont have access to files and directories on host system.

Why?

Because is <strong>VERY IMPORTANT SECURITY</strong> feature to block reading Your disc for files from scripts.

Recommend

  • ngImgCrop not working inside UI Modal
  • Accessing current user information for a netsuite html form using suitescript
  • Should i assign JavaScript events directly just to unify code?
  • Different layers in Corona/Lua
  • How to subscribe on localStorage but not on sessionStorage events
  • Flash and HTTP Status Code 207
  • Trigger anonymous event via chrome/javascript console?
  • JavaScript Event Delegation - Behavior
  • addEventHandler() in a loop has unexpected results
  • triggering js function when any element is clicked on the webpage
  • flash.sensors.Accelerometer on Android within web browser
  • AS3 String Memory Leak
  • Javascript get anchor href on click
  • Phonegap merge directories - assets not being merged
  • Issues with wmode=“opaque” and issues with wmmode=“window”
  • display a overlay when input is clicked in react
  • avoid automatic jump to bottom on page with iframe video
  • Can a variable be stored within an image or div tag?
  • not able to create VC++ project, with VS11
  • button in popup.html not working
  • Remove previous Directions Route Google Maps
  • $_POST for text in DIV elements
  • C++ and JS RegEx equivalent of \\p{L}
  • Return null in boolean to checkbox state converter in XAML
  • Azure table query partial partitionkey guid match
  • SIP API media codecs
  • Making Google Visualization - Annotation Chart to work in GWT
  • Does Apportable support to build library binary (.a/.so)?
  • Update Google Maps traffic layer without page reloading
  • Uncaught TypeError: $(…).select2 is not a function
  • Remove changes from one element when event occurs on another element?
  • Button click event not firing in jQuery
  • Chart.js Multiple dataset
  • How do I get HTML corresponding to current DOM tree?
  • JQuery Internet Explorer and ajaxstop
  • JSON response opens as a file, but I can't access it with JavaScript
  • Change an a tag attribute in JavaScript based on screen width
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?