In a website that uses CKEDITOR to post articles, how do I, as a content creator, upload an image hosted at a third party (e.g: "http://www.tizag.com/pics/htmlT/sunset.gif") by using CKEDITOR's inbuilt upload function?
Back story:
I work at this tutoring website, my job is to read a student's question, and quickly find appropriate answer and post it. Many times I take references from wikipedia, copy-pasting works, but anyone can right click the equation-image, and "open in new tab" to see that it was hosted on wikipedia. Instead of manually downloading and uploading each equation, there must be a way to programatically and (if possible) asynchronously upload them all. I am unable to understand their code, I can't figure out the curl to upload the image. I am hoping for a general javascript code that uses CKEDITOR's functions from my browser's console to upload an image hosted at a third party website. CKEDITOR.version: 4.3.3
Note: I am not the programmer of my work website, so I cannot install add-ons in CKEDITOR's installation folder on the backend. I need a way that uses my browser's console.
There are plugins that will do that for you in CKeditor.
Visit CKEDITOR BUILDER to add any of the plugins below.
First plugin is the Image plugin. See the screenshot.
You can upload an image via URL with this.
The other plugin is the Media Embed plugin
This one as well will do what you want.
Related
The use case of this problem is very simple but i struggle to find a good solution for it.
I want to allow my users (through a webapp) fill some pdf files stored in server (pdf with forms, which begin more and more popular).
Actually, app like chrome or acrobat reader are able to fill them perfectly whe its open locally.
I already allow this functionnality for docx and xlsx files, for that i use Webdav and the custom protocols ms-word ad ms-excel. It works perfectly.
For pdf, I didnt found equivalent. Its look the mains pdf reader/editor doesn't implement this protocol. Whe we open distant file with these tools, they failed for write permission when save or they try to save the file locally) .
Another option i take a look was the new file system access api (https://web.dev/file-system-access/). But again i wasn't able to make it working properly. The main problem here is how we can edit the file.? Im able with this api to dowload the file locally and keep the filehandler to retrieve the updates, but i blocked on how i can edit the file ? like an option on the fileHandler to say "Open this file with default editor on the OS". this would be perfect. But for now to edit the file i have to manually open it on the eplorer. i can't ask my end user to do that there is too many risk they edit the wrong file.
Another option on the table is the different javascript library for editing PDF, but these last one looks all very expensive, usually very heavy on the client side, with advanced features definitively i don't need. I just want to fill the forms and retrieve the pdf completed. So i would like to avoid this option.
Last option i take a look, i already use pdf.js (from mozilla) and pdf-lib.js in my app for some drawing features. I was thinking
rendering the pdf with pdf.js
retrieve all the forms fields (id, type, size, position) of the pdf with pdf-lib
generate html input write on the top of the pdf with the informations given by pdf-lib
i let the users fill the input and click on a save button whe he finished
on the save, i edit my pdf with pdf lib, i set the value of all my forms fields by taking value of the corresponding html input, and i retrieved the pdf updated.
This solution look for me the more "feasible". But im afraid of the volume of development, on how it will render, deal with zoom, rotation, etc. i would like to not have my custom solution.
I precise my webapp target chrome so it make me crazy to not be able to use the chrome pdf viewer/editor to do what i want.
PS : i struggle to post this question on stackoverflow. the previous one was deleted witout i had precise reasons. i try to be more specific on this one, but please if its such a dumb question, please answer it
I feel your pain, this is currently not possible. Adobe acrobat can open PDFs from webdav locations (simply call acrobat.exe and pass in the WebDAV UNC and it will work) but there is no way to trigger this from the browser.
If you are able to deploy software to your customers machines, you could create a custom URL scheme to do this...
I want to open a file in its Windows default application.
Actually, the scenario is as below:
A file is saved in Database and it is shown as a preview in CKEditor
When I double click on that file, it should open in its default application. The file can be a Word or Excel or PDF file
Then the user will edit the file in that default application
And when the user saves that file or closes the document, it should be updated on the server also it should refresh the file preview in CKEditor
I just want to know if there is any way to open the file in its default application.
Things I have tried:
I tried to use the ActiveX object to open the file, but it is not supported in Chrome and Firefox. And anyway, many forums are saying that it is the end of ActiveX era.
Tried to find if there is any CKEditor plugin, but did not find any.
Thank you in advance for your answer.
Short answer: no. Can you imagine the security nightmare if JavaScript was allowed to execute arbitrary binary files on a user's machine?
Your solution is going to be to find a JavaScript library that allows for handling those files, similar to how PDF.js was made for PDFs in-browser.
I am developing an Excel add-in using Office JS in which a user can decide to open a document from a remote server API. In that case I need to receive a file from the server API and open it in Excel.
I already found this answer: Programatically open a excel document using javascript office api
So I see that the API does not allow this, and the answer suggests triggering the download using JS.
So I added an iframe to the addin page:
<iframe id="download" width="1" height="1" style="display:none"></iframe>
And to trigger the document download I am doing:
document.getElementById("download").src = downloadURL;
That works perfectly when trying online (Office 365).
But it is not downloading the document using the desktop version.
How can I make the solution word in desktop Excel application?
Currently, there is no API in Excel to allow you to create/open document programmatically. Word does have it, and there is a suggestion -- currently under investigation-- for doing the same for Excel as well (https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/15034512-ability-to-open-replace-workbook-with-excel-js-api). But, there is not ETA that we can share yet.
That being said, you can absolutely pop up a "save as" dialog. In fact, if you've seen Script Lab, our "Export for publishing" does just that.
For Script Lab, we use the FileSaver NPM package. If you want to see the bit of Script Lab code that makes use of it, see this file, searching the area around FileSaver.saveAs. Note, however, that the save-as dialog does not seem to work correctly on Mac or iOS, so at the moment we limited this functionality to just Desktop and Office Online (you can see a platform check towards the beginning of that method).
Hope this helps!
If I'm understanding what you're trying to do, I have a potential solution.
One way to download a file from a URL with minimal coding is via the command-line with the Background Intelligent Transfer Service (BITSAdmin) Tool included with Windows.
This example downloads a cooking chart, in the background, to the location (and filename) you specify:
Sub testDownloadFileFromCMD()
Const source_downloadURL = "http://instantpot.com/wp-content/uploads/2017/08/Cooking-Time-Tables-1.pdf"
Const dest_PathFilename = "C:\downloadedPDFFile.pdf"
Shell ("bitsadmin /transfer wcb /priority high " & source_downloadURL & " " & dest_PathFilename)
End Sub
It shows the progress window but that can be optionally hidden.
Does your URL work with BITS?
If this doesn't work then there are many other ways to download a file but I'll definitely need more information. I'm not sure what you mean by "the API allows Outlook365 but doesn't allow Excel to download the file". Is the API giving an error? More about this file... Is it Text/Binary? What kind of file. Is it large enough that size could be a problem? Are you able to download the file in other ways, like directly with a browser?
I hope this helps and if not I'll have more to say! :-)
Using Javascript, I'm trying to establish an appropriate method to display a PDF file in a new browser tab. If the browser doesn't have an in-built PDF viewer, I'd like the user to have the option to download the file. My research has led me to John Culviner's jQuery plugin jquery.fileDownload.js here, and that looks a great fit. The issue I have however is that I don't have access to the web server hosting the site in order to upload the plugin. I've also been unable to find a CDN that hosts the plugin and which I could link to.
Does anyone have a few 'best practice' suggestions to achieve my goals that I can research further? Thank you.
There is no need to involve JS. Just link to the PDF. Use the target attribute to trigger a new tab.
<a href="foo.pdf" target="_blank">
If the server lies about the content-type of the PDF or sends a header that indicates it should be downloaded instead of rendered, then you are out of luck.
If you really want to use JS, then:
window.open('foo.pdf');
I have a couple of solutions, but none of them work perfectly.
Platform
ASP.NET / VB.NET / .NET 2.0
IIS 6
IE6 (primarily), with some IE7; Firefox not necessary, but useful
Allowed 3rd Party Options
Flash
ActiveX (would like to avoid)
Java (would like to avoid)
Current Attempts
Gmail Style: You can use javascript to add new Upload elements (input type='file'), then upload them all at once with the click of a button. This works, but still requires a lot of clicks. (I was able to use an invisible ActiveX control to detect things like File Size, which would be useful.)
Flash Uploader: I discovered a couple of Flash Upload controls that use a 1x1 flash file to act as the uploader, callable by javascript. (One such control is FancyUpload, another is Dojo's Multiple File Uploader, yet another is one by darick_c at CodeProject.) These excited me, but I quickly ran into two issues:
Flash 10 will break the functionality that is used to call the multiple file upload dialogue box. The workaround is to use a transparent flash frame, or just use a flash button to call the dialogue box. That's not a huge deal.
The integrated windows authentication used on our intranet is not used when the Flash file attempts to upload the files, prompting the user for credentials. The workaround for this is to use cookieless sessions, which would be a nightmare for our project due to several other reasons.
Java Uploader: I noticed several Java-based multiple-file uploaders, but most of the appear to cost money. If I found one that worked really well, I could arrange to purchase it. I'd just rather not. I also don't like the look of most of them. I liked FancyUpload because it interacted with html/javascript so that I could easily style and manage it any way I want.
ActiveX Uploader: I found an ActiveX solution as well. It appears that ActiveX will work. I would just write my own instead of buying that one. This will be my last resort, I think.
Resolution
I would love to be able to use something like FancyUpload. If I can just get by the credentials prompt some way, it would be perfect. But, from my research, it appears that the only real workaround is cookieless sessions, which I just can't do.
So, the question is: Is there a way to resolve the issues presented above OR is there a different solution that I have not listed which accomplishes the same goal?
I don't think there is any work around for the integrated windows authentication. What you could possibly do is save the files to a generic unprotected folder and, in the case of swfupload, use a handler to move the file when its fully uploaded
You could try SWFUpload as well - it would fit in your Flash Uploader "category".
Our company uses https://ajaxuploader.com which supports this feature.
In Internet Explorer, FileReference.upload (flash upload) will send cookies along as well.
This behavior breaks only when running in other browsers.
#davidinbcn.myopenid.co: That's basically how I solved this issue. But, in an effort to provide a more detailed answer, I'm posting my solution here.
The Solution!
Create two web applications, or websites, or whatever.
Application A is a simple web application. The purpose of this application is to receive file uploads and save them to the proper place. Set this up as an anonymous access allowed. Then make a single ASPX page that accepts posted files and saves them to a given location. (I'm doing this on an intranet. Internet sites may be exposing themselves to security issues by doing this. Take extra precautions if that is the case.) The code behind for this page would look something like this:
Dim uploads As HttpFileCollection = HttpContext.Current.Request.Files
If uploads.Count > 0 Then
UploadFiles(uploads)
Else
result = "error"
err = "File Not Uploaded"
End If
Application B is your primary site that will allow file uploads. Set this up as an authenticated web application that does not allow anonymous access. Then, place the FancyUpload (or similar solution) on a page on this site. Configure it to post its files to Application A's upload ASPX page.