Auto enable flash for site in asp.net - asp.net

I'm using Uploadify.swf file to upload certain type of files to my dropbox account. However when the flash is not detected or it is not enabled, the files are not uploaded. As being a developer i have generated a popup message for this issue. But I'm trying to find if there is any way the flash for the site gets enabled automatically, without done manually.
Similarly the swf files is not supported on Firefox. It works fine on Chrome and Internet Explorer.
Below is my code
$(document).ready(function () {
$("#<%=FileUpload1.ClientID%>").uploadify({
swf: 'scripts/uploadify.swf',
uploader: 'Upload.ashx',
cancelImg: 'Content/cancel.png',
auto: true,
multi: true,
method: 'POST',
//fileTypeExts: '*.jpg; *.png; *.gif; *.bmp; *.jpeg; *.JPG; *.pdf; *.doc; *.docx;',
buttonText: 'Upload File',
width: 130,
onUploadSuccess: function (file, data, response) {
console.log("sucess");
console.log(data);
var filName = file.name + Math.random();
console.log(filName);
$("#attachedfiles").append("<tr><td>" + file.name + "</td><td><a onclick=\"deleteHostTable(this);\" href = 'javascript:;'>[x]</a></td></tr>");
},
onFallback: function () {
alert('Flash was not detected or flash version is not supported.');
}
});
});

Firefox and Chrome already disable flash by default. While an end-user still can enable it, flash technology seems to be outdated.
I use a third-party upload component to upload files to Amazon. It also supports DropBox upload out of the box.

Related

Electron webContents.printToPDF doesn't work for webpages containing iframe

I am trying to convert my webpage to PDF using webContents.printToPDF. Most of the times its working fine but for pages containing iframe which I am using for youtube videos this method doesn't end at all. To update the electron version is impossible for my application. I tried to use webview in the place of iframe which was also not helping. Is there any way to fix this in the same version of electron.
Electron version : 5.0.13
OS: mac OS, Windows
win.webContents.printToPDF({
printBackground: true,
landscape: false,
marginsType: 1,
pageSize
}, (error, data) => {
console.log('Inside printToPDF callback')
if(error) {
showMessage("Unable to export PDF")
return console.log(error.message);
}
fs.writeFile(filePath, data, (err) => {
if (error) {
showMessage("Unable to export PDF")
return console.log(error.message);
}
console.log('Write PDF successfully!');
showMessage(`PDF exported successfully !`);
});
});
For pages containing iframe, the log "Inside printToPDF callback" is never printed.

Firesbase Storage - force download of an image

I would like to force a download of an image stored in Firebase Storage, but the download attribute in HTML anchors does not support cross-domain and I can't change the content-type to application/octet-stream because it's used to generate a thumbnail.
How can it be done ?
In this case, you cannot use a simple 'download' in html anchors.
What you can do is sending your download request through javascript.
There is an official sample for downloading.
storageRef.child('images/stars.jpg').getDownloadURL().then(function(url) {
// `url` is the download URL for 'images/stars.jpg'
// This can be downloaded directly:
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function(event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
// Or inserted into an <img> element:
var img = document.getElementById('myimg');
img.src = url;
}).catch(function(error) {
// Handle any errors
});
about cross domain
download image example
more about web firebase
I had a similiar issue with downloading an mp4 video file. The browser seemed to ignore any download attribute in my html anchors. So my solution was to request the Blob from firebase like so wich also helps hiding an url to the file in storage:
await getBlob(storageRef(storage, path))
.then((blob) => {
downloadUrl.value = URL.createObjectURL(blob);
}
now the browser (including ios) directly triggers a download instead of opening the video in the browser by clicking the anchor:
<a :href="downloadUrl" download="videofile">Download</a>

Wordpress on iOS requires refresh before uploaded pictures can be seen or viewed

I am launching a wordpress based website which has a custom wordpress open_media window. When I am adding media from iPhone (in Chrome or Safari), I am able to upload pictures from my photo library but they do not show up immediately for use. I get no errors. To find the photo I have to exit out of the media window and refresh my browser then reenter the open media window and the picture will be there.
Has anyone experienced this problem?
function open_media_window() {
var upload = "";
$post_div = $(this).closest('.bizimg-select');
if (this.window === undefined) {
if($(this).hasClass('bizimg-select')){
upload = "bizimg";
}
if($(this).hasClass('vcard-file')){
upload = "vcard";
}
if(upload=='bizimg'||upload==""){
this.window = wp.media({
title: 'Upload my Bizcard Bizimg',
library: {type: 'image/*'},
multiple: false,
button: {text: 'Insert'}
});
}
if((upload=='vcard')){
this.window = wp.media({
title: 'Upload my Bizcard vCard',
library: {type: 'text/x-vcard'},
multiple: false,
button: {text: 'Insert'}
});
}
var self = this;
this.window.on('select', function() {
var files = self.window.state().get('selection').toArray();
var first = files[0].toJSON();
if(upload=='bizimg'){
//do some stuff here
}
if(upload=='vcard'){
//do a bunch of stuff here
}
});
}
this.window.open();
return false;
}
I was mistaken that this issue was restricted to mobile connections only. After much digging and trying to learn more about js backbone and wordpress wp.media (which remains relatively undocumented, by the way), I did figure it out. Using 'image' instead of 'image/*' in the library options allowed the upload to load into the media library screen. 'image/*' was the problem. See below the options that worked for me.
wp.media({
title: 'Upload my Bizcard Bizimg',
library: {type: 'image'},
multiple: false,
button: {text: 'Insert'}
});

Applying file filter in RadAsync File upload control

How to enforce user to see only those specific types of files which he has allowed while browsing for files to upload through RadAsyncUpload Control .
Only the Silverlight upload module can do that, as otherwise you have no access to the OS in order to filter the File Selection dialog.
Thus, IE8 and IE9 have that OOB, just open this demo in either of them: http://demos.telerik.com/aspnet-ajax/asyncupload/examples/overview/defaultcs.aspx
You can force the SL plugin to be the only used plugin with the following code (at your own discretion, you will lose FileAPI for modern browsers):
<script>
Telerik.Web.UI.RadAsyncUpload.Modules.Flash.isAvailable = function () { return false; };
Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable = function () { return true; };
Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable = function () { return false; };
</script>

How to ignore "Content-Disposition: attachment" in Firefox

How can I cause Firefox to ignore the Content-Disposition: attachment header?
I find it absolutely annoying that I can't view an image in the browser, because it asks me to download it.
I don't want to download the file, I just want to view it in the browser. If the browser doesn't have a plugin to handle it, then it should ask to download.
E.g. I have Adobe Acrobat Reader installed as a plugin for Firefox. I click a link to a PDF, and it asks me to save it, when it should open in the browser using the plugin. This is the behaviour if the server does not send the Content-Disposition: attachment header in the response.
Firefox 3.6.6
Windows XP SP3
Legacy InlineDisposition 1.0.2.4 by Kai Liu can fix this problem.
In the Classic Add-ons Archive at:
caa:addon/inlinedisposition
The "Open in browser" extension is useful for formats supported natively by the browser, not sure about PDF.
Legacy version 1.18 (for users of browsers such as Waterfox Classic) is in the Classic Add-ons Archive at:
caa:addon/open-in-browser
I also found this tonight that totally prevents Firefox from littering your desktop with downloads. It's actually a redirect fix to the hidden /private/temp folder in MAC. Genius.
You can mimic the Windows behaviour simply by changing [Firefox's]
download directory to /tmp.
To do this, open Firefox's General preferences pane, under Save
Downloaded Files To select [choose].... In the dialog that appears,
hit Shift-Command-G to bring up the Go to Folder dialog.
In this dialog, simply type /tmp, hit OK, then hit Select in the
main window.
Well, that's the purpose of disposition type "attachment".
The default behavior (when the header is absent) should be to display in-line.
Maybe there's a configuration problem in your browser, or the Reader plugin?
For PDFs there is an addon called PDF-Download which overrides any attempt to download a PDF and lets the user decide how they want it downloaded (inline, save, external, etc). You could probably modify it to work for other filetypes too.
You could write a firefox extension that removes the disposition header for PDF files. This would be a fairly simple extension.
Since I was looking for a solution and no available add-on was actually working with my Firefox 31.0 (Ubuntu) I decided to try creating my own add-on.
The code if you want to archive a similar goal or just want to know how it works.
console.log("starting addon to disable content-disposition...");
//getting necessary objects
var {Cc, Ci} = require("chrome");
//creating the observer object which alters the Content-Disposition header to inline
var httpResponseObserver = {
//gets fired whenever a response is getting processed
observe: function(subject, topic, data) {
if (topic == "http-on-examine-response") {
var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
httpChannel.setResponseHeader("Content-Disposition", "inline", false);
}
},
//needed for this.observerServer.addObserver --> without addObserver will fail
get observerService() {
return Cc["#mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
},
//used to register with an observer
register: function() {
console.log("register with an observer to get response-events");
this.observerService.addObserver(this, "http-on-examine-response", false);
},
//used to unregister from the observer
unregister: function() {
console.log("unregister from observer");
this.observerService.removeObserver(this, "http-on-examine-response");
}
};
//gets called at enable or install of the add-on
exports.main = function(options, callbacks) {
console.log("content-dispostion main method got invoked");
//call register to make httpResponseObserver.observe get fired whenever a response gets processed
httpResponseObserver.register();
};
//gets called on disable or uninstall
exports.onUnload = function(reason) {
console.log("content-dispostion unloaded");
//unregister from observer
httpResponseObserver.unregister();
};
/*
//not needed!!! just test code for altering http-request header
var httpRequestObserver =
{
observe: function(subject, topic, data)
{
console.log("in observe...");
console.log("topic is: " + topic);
if (topic == "http-on-modify-request") {
var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
httpChannel.setRequestHeader("X-Hello", "World", false);
}
},
get observerService() {
return Cc["#mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
},
register: function()
{
this.observerService.addObserver(this, "http-on-modify-request", false);
},
unregister: function()
{
this.observerService.removeObserver(this, "http-on-modify-request");
}
};
httpRequestObserver.register();
*/
As an alternative you can get my xpi-File to directly install the add-on in Firefox. If you want to disable the "Content-Disposition" altering just deactivate the add-on ;-).
http://www.file-upload.net/download-9374691/content-disposition_remover.xpi.html

Resources