I am confused on how to do this.. Currently I am implementing an automatic download using Javascript:
target.appendJavaScript("location.href='"+ "./Access.xls" + "';");
This doesn't work.. What is the proper way to trigger an automatic download and how do I properly set the url? I am not too familiar with Javascript but trying to implement this. The file is in the root of the project.. but it tells me it is not found.
Also, when the user downloads it, I would like to then delete it right away after it is downloaded using Javascript, how can I do this? I am using Javascript because I am calling this file within an ajax method.
Thanks!
The best way to get access to that resource, you should use a ResourceReference as explained here. To get the url of a ResourceReference use:
RequestCycle#urlFor(ResourceReference, PageParameters)
However, I don't understand what you need regarding deletion of the file once downloaded. If your file is contained in the jar/war of your project, I don't believe it can be deleted from inside the web app. You could block access to it once it's downloaded however, if that makes sense. Not sure what you're trying to achieve here.
Related
I did not have programming background and I learned to code completely by Google search so please excuse me if the question is not totally clear. I tried to search a this issue but could not find an answer.
I have built a website with React + Golang (Beego framework). Now I am trying to add a sitemap.xml to my website so that when people go to mywebsite.com/sitemap.xml, they will see the sitemap. I already generated the xml file but I am not sure where to put it.
I tried to set a URL in Golang as /sitemap.xml but Golang (Beego) does not render xml file and shows an error. I can put that file into folder static and access that file at mywebsite.com/static/sitemap.xml but I want it to be mywebsite.com/sitemap.xml.
I think I am trying to do it the wrong way. Really appreciate any advice.
I am relatively new to ServiceNow, and I am building some UI pages where I basically do not need any of the SN structure except for Glide Ajax (I need to get data from a Script Include).
The problem is that when I select "Direct" the Glide Ajax functions are not available any more in the client script.
Does anybody know if this is possible to achieve? I searched everywhere without success.
Thanks a lot!
If you check "Direct", it omits all ServiceNow specific JavaScript and CSS. "GlideAjax" is ServiceNow specific JavaScript.
If the data that you are pulling back from the Script Include is static (meaning that you can pull it when the UI page is loaded) then you can probably do it inside an "evaluate" block in the HTML section of the UI page. You could have your Script Include return a JSON object as a string and store it in a variable. Then you could have your client JavaScript parse that variable. I am not a Jelly expert, so I would be curious to know if it works.
Using the jQuery wrapped version of Fineuploader v3.3.
Is it possible to populate the file list with files already in the upload folder?
I think "_addToList(id, name)" should do the trick, but I can't get it to work. Any ideas?
Seems that they are currently working on this feature:
https://github.com/Widen/fine-uploader/issues/784
So, this will be available soon.
This is not a behavior that Fine Uploader currently supports. Fine Uploader only displays files that users have submitted to the uploader since the current uploader instance was created. It doesn't try to be an all-in-one web application. You could probably add your own item to the list/UI via javascript. That probably wouldn't be terribly difficult, but seems like an odd thing to do.
If you'd like to discuss your specific use case more, please open up a feature request in the Github issue tracker.
Generally, client side code cannot add stored or hard-coded path based file names for use in any type of POST or upload operation. Obviously this is a security measure, you can imagine if a malicious web page could add to a generic POST operation some type of baked in file name. So from what I understand, only the user can specify path based file names, via a file browser for the session that it is included in. This applies to HTML/JavaScript/jQuery but am unsure if Flash/Silverlight based solutions would also be limited. I think a Java based uploader would be free of this. But you are just moving closer and closer to installed software.
I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: Settings
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Take a look at the config class. It allows you to make custom config files.
It's not entirely made for URL's but you sure can use them.
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url() function.
Yes, it's called Routes, configuration located at config/routes.php. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url() in conjunction with constants, for example site_url(URL_SETTINGS);, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.
I am trying to implement a comment mechanism in which a user can post a comment and also upload multiple files with it. I am using a g:formRemote for the comment part but I learned that ajax request does not supports file uploads. SO how do I do this? I found few plugins but they did not work for me as I have to save comments as well and these plugins did not support that. I found a way on internet by using iframes, but I am not sure how to do that. Any help would be very appreciated. Thanks
Try to use jQuery Form plugin, it supports ajax file uploads as well so you don't need to implement this by yourself. It also allows to track upload progress.