Read File stored on some URL using HTML5 File API - javascript

I'm using HTML5 file API to upload files to my web application.
I have an input element on my web page using which I read files and call upload function
<input type="file">
$('input[type="file"]').on("change",function(e){
console.log(this.files);
// upload each file in this.files
});
This works perfectly for native files on os. I want to now upload remote files e.g., example.com/blah/file1.jpg My question is how do I read this file using File API? Is there a way to do it?

You can download remote files over XMLHttpRequest, and process them as Blob. Then upload it to another server. The upload has to be over XMLHttpRequest. It relies on the browser's implementation of XHR Level 2. This link contains the code snippets you will need:
http://www.html5rocks.com/en/tutorials/file/xhr2/
It has both snippets for downloading remote file as a Blob and uploading a Blob to a server.

Related

I have created pdf from html now I want to upload this pdf to cloudinary or our my server without saving it to client pc

I have created pdf from html now I want to upload this pdf to cloudinary or our my serverwithout saving it to client pc. I'm using Angular 4 on front-end
You can use Upload API to upload server-side. https://cloudinary.com/documentation/image_upload_api_reference#upload_method

How to download pdf file using vuejs and bootstrap-vue

I'm trying to upload a pdf file to my browser, but I want to be able to download this file afterwards. I am having problems on the second task - downloading it.
I'm uploading as follow:
<b-form-file v-model="form.file" :state="Boolean(form.file)" placeholder="Choose a file..."></b-form-file>
How can I download form.file content after upload is done?
Edit:
I found this API, which handles file downloads nicely.
You need to save the file somewhere on your server or on a storage service (ie Amazon S3) and then redirect the user to a link where the file itself is served.
The specific implementation is based on your backend implementation and your architectural choices.

How to save file in HTML FileSystem API using mt-downloader?

I am using mt-downloader to download and save files from server. It works fine when i save the file in system filesystem like
/var/datafiles/filename.ext
But i am getting error when i try to save the file using HTML Filesystem API. It says
Error: Invalid File Path
Go with
https://github.com/eligrey/FileSaver.js/
the HTML Filesystem API is still not standart

Html 5 file upload and how to send a file from a browser to backend

I've seen a few tutorials of how to use Html5 File API such as this https://www.html5rocks.com/en/tutorials/file/dndfiles/ for file uploading. What I want is a few pointers of how to send all that from a browser to backend and process it there to actually upload files. In those tutorials it's not shown.
The backend language doesn't matter.
And I don't want to use an external js library, only pure javascript.

Reading remote PDF files with JavaScript

I'm working on an iphone app, that would read pdf files from the folder on web server.
I made the part of app which read PDF files and everthing is fine, now i'm trying to figure out how to load all pdf files from http:/www.blabla.com/pdf, so everytime i upload new pdf, the app would automaticly load it.
Is this possibile, and anybody has ideas how can be done?
This can only be done, by either having Directory Index enabled, or using a server side language such as PHP to read the contents of that folder and output the filenames.

Categories

Resources