swf will not work on server. Runs fine locally - spring-webflow

I have a banner (XML_Banner.swf) that is supposed to load and rotate images from an XML file (banners.xml). When I preview my the site locally, I get no problems. However, once on the Linux web server the movie seems to load but displays no pictures. Just a black box. If I navigate to the banner it also loads with no problem.
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner/XML_Banner.swf
It is probably a very simple fix that I keep overlooking. Here are some details:
The banner files are located in a folder entitled "banner" inside the root folder for the site.
I have placed the files XML_Banner.swf, XML_Banner.html, and banners.xml inside the folder "banner".
Images for the banner are located in a folder "img" inside of "banner".
The file (AC_RunActiveContent.js) is located inside a folder named "Scripts" inside the banner folder.
Referencing the file:
<script type="text/javascript" src="Scripts/AC_RunActiveContent.js"></script>
Embedding code:
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="878" HEIGHT="220" id="XML_Banner" ALIGN="">
URL:
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/index.html
EDIT
Here is my XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<rotator isRandom="false">
<bannerTime>5</bannerTime>
<numberOfBanners>7</numberOfBanners>
<banners showHeader="true">
<banner>
<name>Arrival of Spring.</name>
<body></body>
<imagePath>img/01.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Fishing in Peru.</name>
<body></body>
<imagePath>img/02.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Peruvian Cattle.</name>
<body></body>
<imagePath>img/03.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Shoreline of Port Hawksbury, NS.</name>
<body></body>
<imagePath>img/04.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Lilies afloat.</name>
<body></body>
<imagePath>img/05.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Logging road.</name>
<body></body>
<imagePath>img/06.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Small rapids.</name>
<body></body>
<imagePath>img/07.jpg</imagePath>
<link>gallery.html</link>
</banner>
</banners>
</rotator>
EDIT Here is my AS:
//Load from XML File
stop();
//Banner
var banners:Array = new Array();
//Image Path
var imagePaths:Array = new Array();
//Link URL
var links:Array = new Array();
//Body Text
var bodyTexts:Array = new Array();
//
var imageTime:Number;
//
var numberOfBanners:Number;
//
var isRandom:String;
//
var showHeader:String;
//
var bannersXML:XML = new XML();
bannersXML.ignoreWhite = true;
bannersXML.load("banner/banners.xml");
bannersXML.onLoad = function(success) {
if (success) {
trace("XML LOADED");
imageTime = parseInt(this.firstChild.firstChild.firstChild)*1000;
numberOfBanners = parseInt(this.firstChild.childNodes[1].firstChild);
isRandom = this.firstChild.attributes["isRandom"];
showHeader = this.firstChild.childNodes[2].attributes["showHeader"];
var bannerSequence:Array = new Array();
if (isRandom == "true") {
//Make a random sequence
while (bannerSequence.length<numberOfBanners) {
newRandomNumber = random(numberOfBanners);
//Make sure that the random one chosen is not already chosen
for (var i = 0; i<=bannerSequence.length; i++) {
if (newRandomNumber != bannerSequence[i]) {
alreadyThere = false;
} else {
alreadyThere = true;
break;
}
}
//Add only random values that aren't in the array
if (!alreadyThere) {
bannerSequence.push(newRandomNumber);
}
}
} else {
for (var i = 0; i<numberOfBanners; i++) {
bannerSequence.push(i);
}
}
}
//Read XML in the Random Order Chosen
for (var i = 0; i<numberOfBanners; i++) {
banners.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].firstChild.firstChild.toString());
bodyTexts.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[1].firstChild.nodeValue);
imagePaths.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[2].firstChild.nodeValue);
links.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[3].firstChild.nodeValue);
}
play();
};
//Start the image counter at 0
var imageCounter = 0;
stop();
//Check to see if the banner should be reset
if (imageCounter>=banners.length) {
imageCounter = 0;
}
//Load banner image
var imageLoader:MovieClipLoader = new MovieClipLoader();
imageLoader.loadClip("banner/img/"+imagePaths[imageCounter],bannerContainer_mc);
var loadingListener:Object = new Object();
loadingListener.onLoadComplete = function() {
play();
//Display Header
if (showHeader == "true") {
imageText_mc.headerTxt.text = banners[imageCounter].toString();
} else {
imageText_mc.headerTxt.text = "";
imageText_mc._alpha = 0;
}
//Button and Link Handling
if (links[imageCounter] != null) {
trace("LINK : "+links[imageCounter]);
bannerContainer_mc.onRelease = function() {
getURL(links[imageCounter], "_self");
};
} else {
delete bannerContainer_mc.onRelease;
}
};
imageLoader.addListener(loadingListener);
Is there something incorrect or am I missing anything?
Any help would be greatly appreciated. Many, many thanks in advance.

The problem is, you have wrong urls. The swf searches for your images at
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/img/01.jpg
but they are located in
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner/img/01.jpg
You can add this relative path in your xml banner/img/01.jpg as source or have a flashVar with that relative path. You have to modify your AS code to use this relative path, if given.
The swf takes relative url's from the base url of the HTML it is included, not where the swf resides.

Related

View not returned properly in ASP.NET MVC Core 6

On click of the button, a javascript function is called that captures the snapshot from the camera and sends it to process. On backed, we get the image and do some process and get the data in an object called "doc". Upto here the system works fine, but the data that I got in "doc" object doesn't seem to be printed on the page.
Here's the button
<input type="button" value="Capture Snapshot" onClick="CaptureSnapshot()">
And here's the javascript
<script language="JavaScript">
function CaptureSnapshot() {
Webcam.snap(function (data) {
// display results in page
document.getElementById('results').innerHTML = '<img src="' + data + '"/>';
// Send image data to the controller to store locally or in database
Webcam.upload(data,
'/Home/UploadFile',
function (code, text) {
Webcam.reset();
//alert('Snapshot/Image captured successfully...');
});
});
}
</script>
And this is the C# method written in the controller
public async Task<IActionResult> UploadFile()
{
var files = HttpContext.Request.Form.Files;
if (files != null && files.Count > 0)
{
foreach (var uploadedFile in files)
{
if (uploadedFile.Length > 0)
{
var fileName = uploadedFile.FileName;
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", fileName);
HttpContext.Session.SetString("UploadedFile", fileName);
byte[] imageBytes = ConvertToBytes(uploadedFile);
Document doc = ProcessDocumentImage(imageBytes);
ViewData["Document"] = doc;
}
}
}
else
return Content("file not selected");
return View("Index", "Home");
}
If I put a breakpoint on "doc", I get the data but it doesn't go on the page. What I found is that the page is not submitted at all, maybe this is the reason.
Any ideas to solve this?

Cannot able to play mp3 file in telerik : rad media player

I am not able to play the mp3 file in telerik rad media player.
Here is my try:
string filePath =Server.MapPath("~/App_Temp/") + "test.mp3";
if (testAudios != null)
{
byte[] bytes =Convert.FromBase64String(testAudios.FirstOrDefault().reAudio);
using (var audioFile = new FileStream(filePath, FileMode.Create))
{
audioFile.Write(bytes, 0, bytes.Length);
audioFile.Flush();
}
}
var file = new MediaPlayerAudioFile() { Title = "RESPONSE AUDIO" };
file.Sources.Add(new MediaPlayerSource()
{ Path = filePath, MimeType = "audio/mpeg" });
player.Playlist.Add(file);
this code is not working. I have checked the path, it's working. I have tried the same path with html directly. Its working successfully.
My html try is:
<telerik:RadMediaPlayer ID="player" runat="server" Width="320px" BackColor="Black"
StartVolume="80" Height="200px">
<Sources>
<telerik:MediaPlayerSource Path="~/App_Temp/test.mp3" />
</Sources>
</telerik:RadMediaPlayer>
It looks like the Path string filePath =Server.MapPath("~/App_Temp/") + "test.mp3"; you specified here isn't exactly suitable for the RadMediaPlayer in the code behind.
Try changing to a relative path should make it work for you. Something like below
var filePath = Page.ResolveUrl("~/App_Temp/test.mp3");
var file = new MediaPlayerAudioFile() { Title = "RESPONSE AUDIO" };
file.Sources.Add(new MediaPlayerSource() { Path = filePath, MimeType = "audio/mpeg", });
player.Sources.Clear();
player.AutoPlay = false;
player.Playlist.Add(file);
Hope it helps

Mobile upload using a different image button immediately after selecting image?

I would like to use my own .png image to trigger a
<input type="file" id="pictureCapture" accept="image/*; capture=camera" />
and then instantly upload the image to an MVC controller.
So, the first question is how to replace the input tag with a clickable image?
And second, thus far, I've only seen file upload as a 2 part process. You click the browse button, select your file, then click Upload to send the file.
How do I consolidate it so that right after you select the file, it uploads?
Is there a 3rd party control that does all this for me?
Here's what I ended up doing:
Html:
<input type="file" id="pictureCapture" accept="image/*; capture=camera" style="visibility:hidden;" />
<img src="#(Url.Content("~/Images/Mobile/Camera.png"))" />
Javascript:
<script>
$("#uploadPhotoFromCamera").click(function (e) {
e.preventDefault();
$("#pictureCapture").trigger("click");
});
$('#pictureCapture').on("change", function () {
var formdata = new FormData(); //FormData object
var fileInput = document.getElementById('pictureCapture');
//Iterating through each files selected in fileInput
for (i = 0; i < fileInput.files.length; i++) {
//Appending each file to FormData object
formdata.append(fileInput.files[i].name, fileInput.files[i]);
}
//Creating an XMLHttpRequest and sending
var xhr = new XMLHttpRequest();
xhr.open('POST', '#(Url.Action("UploadMobile", "Document"))')
xhr.send(formdata);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
alert('success');
}
}
return false;
});
</script>
Controller:
public virtual ActionResult UploadMobile()
{
List<HttpPostedFileBase> files = new List<HttpPostedFileBase>();
for (int i = 0; i < Request.Files.Count; i++)
{
files.Add(Request.Files[i]); //Uploaded file
}
// Do whatever now with your list of files
return Json("Uploaded " + Request.Files.Count + " files");
}

jQuery and #Html.TextBoxfor()

I currently have the following code:
[HttpPost]
public ActionResult Index(IList<LocalPageModel> postPages,
IEnumerable<HttpPostedFileBase> files)
{
if (ModelState.IsValid)
{
foreach (HttpPostedFileBase file in files)
{
if ((file != null) && (file.ContentLength > 0))
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/"),
fileName);
file.SaveAs(path);
}
}
}
else
{
ManagePagesModel mod = new ManagePagesModel
{
PostPages = postPages
};
return View("Index", mod);
}
return RedirectToAction("Index");
}
In my view, I have a JavaScript button which will add a div so that the user can post another page such as:
$("#add-page").click(function () {
$("#page").append('<div id="page"> #Html.TextBoxFor(u => u.PostPages[0].Title) </div>');
});
How do I make it so that when the user clicks on the JavaScript button, the new text will be appended to the page and u.PostPages[x] will be incremented?
If you want to do it all on the client (no AJAX), maybe don't use the MVC helpers at all, and do it manually instead - you know the HTML that will be rendered, so just do that:
var i = 0;
$("#add-page").click(function () {
$("#page").append('<input type="text" name="PostPages[' + (i++) + '].Title">');
});
Maybe clean the code up a bit so the quotes don't get too confusing, but you get the idea...
You didn't past your view, but I assume you have the following at the top:
#model = ManagePagesModel
If that's the case, you can then use the following #foreach to loop through the page models:
$("#add-page).click(function() {
#foreach(var pageModel in Model.PostPages){
$("#page").append('<div id="page"> #Html.TextBoxFor(u => pageModel.Title) </div>');
});
To increment u.PostPages[x] you may use following code:
<script>
var i = 0;
$("#add-page").click(function () {
i++
$("#page").append('<div id="page"> #Html.TextBoxFor(u => u.PostPages['+i+'].Title') </div>');
});
</script>
Here is small working example: jsfiddle

IE9 - Information Bar to download file appears on Parent Window; not current

Original Post
One of the features of my Web App is that it prints reports. These reports require a pop-up window allowing the user to refine the parameters of the report. This cannot change.
Pre-IE9, when the user clicked my "Preview" button on the pop-up window, they would get a dialog like this once the report rendered:
This is easy and intuitive to my clients.
However, after upgrading to IE9, the Message Bar (Information Bar/Download Bar) whatever it's called, shows in the PARENT window of the pop-up:
In order to download or open the report, the user is now required to close the pop-up window and then select the appropriate action on the Download Bar.
This is a pretty frustrating work-around.
I've looked for ways on the net to either show the the Download Bar on the pop-up window (preferred), revert to the old dialog, or remove it all together.
No solutions yet. If anyone has any IE solutions/work-arounds, please post them.
Update
UPDATE ON THIS UPDATE The steps below do expose a bug, but not one related to my issue as it happens on all versions of IE. I think it's close but I will need to look test more to get the precise issue.
Ok, so I looked deeper in the code and whittled it down enough to produce an issue. It's actually different than my original issue (grrr), but perhaps related.
What you need:
Windows 7
IIS 7.0
Create the following four files:
PageOne.htm with the following contents:
<html>
<head>
<script type="text/javascript">
window.dialog = new Object();
var myFunc = function() { window.alert('hello')};
function test(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open = function(sUrl, fpReturn, bNoResize) {
window.dialog.__returnFunction = fpReturn;
window.dialog.returnValue = null;
window.dialog.arguments = new Array();
for (var x = 2; x < arguments.length; x++) {
window.dialog.arguments[x - 2] = arguments[x];
}
window.dialog.arguments[window.dialog.arguments.length] = window;
sUrl += new Date().getTime().toString();
var sFeatures;
var nWidth = 500; var nHeight = 500; var nLeft = 100; var nTop = 100;
if (window.dialog.position) {
nLeft = window.dialog.position.left;
nTop = window.dialog.position.top;
window.dialog.position = null;
}
if (sUrl.indexOf("?") != -1) {
var pairs = sUrl.split("?")[1].split("&");
var aValue, pos;
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].toUpperCase().indexOf("SIZE") == 0) {
aValue = pairs[i].split("=")[1].split(",");
if (aValue.length == 2) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
break;
} else if (aValue.length == 4) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
nLeft = parseInt(aValue[2]);
nTop = parseInt(aValue[3]);
break;
}
}
}
}
nTop -= 1;
sFeatures = "";
window.dialog.arguments._gotoURL = sUrl;
window.dialog.arguments._dialogTitle = 'my title';
window.dialog.returnValue = window.showModalDialog("DummyDialog.htm", window.dialog.arguments, sFeatures);
};
</script>
</head>
<body>
Test Window
</body>
</html>
DummyDialog.htm with the following contents:
<html>
<head>
<script type="text/javascript">
window.dialog = new Object();
var myFunc = function() { window.alert('hello')};
function test(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open = function(sUrl, fpReturn, bNoResize) {
window.dialog.__returnFunction = fpReturn;
window.dialog.returnValue = null;
window.dialog.arguments = new Array();
for (var x = 2; x < arguments.length; x++) {
window.dialog.arguments[x - 2] = arguments[x];
}
if (true) {//if (is.ie) {
window.dialog.arguments[window.dialog.arguments.length] = window;
}
sUrl += new Date().getTime().toString();
// in pixels
var sFeatures;
var nWidth = 500;
var nHeight = 500;
var nLeft = 100;
var nTop = 100;
if (window.dialog.position) {
nLeft = window.dialog.position.left;
nTop = window.dialog.position.top;
window.dialog.position = null;
}
if (sUrl.indexOf("?") != -1) {
var pairs = sUrl.split("?")[1].split("&");
var aValue, pos;
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].toUpperCase().indexOf("SIZE") == 0) {
aValue = pairs[i].split("=")[1].split(",");
if (aValue.length == 2) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
break;
} else if (aValue.length == 4) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
nLeft = parseInt(aValue[2]);
nTop = parseInt(aValue[3]);
break;
}
}
}
}
nTop -= 1;
sFeatures = "";
window.dialog.arguments._gotoURL = 'download.aspx?file=MyTestFile.txt';
window.dialog.arguments._dialogTitle = 'my title';//window.getTitle();
window.dialog.returnValue = window.showModalDialog('download.aspx?file=MyTestFile.txt', window.dialog.arguments, sFeatures);
};
</script>
</head>
<body>
Test Window
</body>
</html>
download.aspx with the following contents:
<%# Page language="vb" runat="server" explicit="true" strict="true" %>
<script language="vb" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim strRequest As String = Request.QueryString("file") '-- if something was passed to the file querystring
If strRequest <> "" Then 'get absolute path of the file
Dim path As String = Server.MapPath(strRequest) 'get file object as FileInfo
Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server
If file.Exists Then 'set appropriate headers
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End 'if file does not exist
Else
Response.Write("This file does not exist.")
End If 'nothing in the URL as HTTP GET
Else
Response.Write("Please provide a file to download.")
End If
End Sub
</script>
MyTestFile.txt with the following contents:
<Root>
<Tag>Hello World</Tag>
</Root>
Now do the following:
Drag all four files to your IIS directory and navigate to PageOne.htm.
Click Test Window (DummyDialog.htm should popup)
Click the hyperlink in that PopUp (this should take you to http://localhost/download.aspx?file=MyTestFile.txt)
What's supposed to happen is that you should be prompted for download. Instead, what I get is a blank window that does nothing. See below:
If you take that same url http://localhost/download.aspx?file=MyTestFile.txt and paste it directly into a new IE window or, alternatively, run the same steps above in Firefox, you'll be prompted for download.
So why would a popup in IE bring nothing but a blank window?
One solution would be to not use a pop-up window, but to use a pop-in window like a jQuery UI dialog. This would give you much more control over things, and would also keep them in the same window so that your users don't miss the ie9 download bar.
Another option might be to have the parameters determined on a new page, rather than a pop-up window.

Resources