简体   繁体   中英

How can I convert a file (pdf/doc) served at a url into json / string / base64 format without downloading on local?

Let's say a pdf document is served at a url, ex - https://www.polyu.edu.hk/iaee/files/pdf-sample.pdf

I need to run a javascript that takes the url and makes a post request to a server with the pdf file data that can be converted back to file. Typical solutions for accessing files on a server location are around downloading on local first and then having the user upload it. How can we bypass the user interference ? Appreciate all inputs and workarounds like using browser cache / local storage etc.

Thanks

This is not possible.

JavaScript executed in a browser runs on the client machine. Thus any modification on a remote resource must be downloaded, modified and uploaded to the server.

As you already stated: using a browser cache or local storage wont help you.

You have to do this modifications on server-side eg with a servlet or php. You will need access to the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM